From 81aabe9e191446680edfcbbb965d4ea9de5c1e8f Mon Sep 17 00:00:00 2001 From: PanLi320 <854954082@qq.com> Date: Sun, 30 Oct 2016 23:33:02 +0800 Subject: [PATCH 01/22] =?UTF-8?q?REPORT-364=20=E6=8A=A5=E8=A1=A8=E5=9D=97?= =?UTF-8?q?=E5=88=B7=E6=96=B0=E5=92=8C=E8=87=AA=E9=80=82=E5=BA=94=E9=87=8D?= =?UTF-8?q?=E5=A4=8Dbug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fun/impl/AbstractFormElementCaseEditorProvider.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/designer_base/src/com/fr/design/fun/impl/AbstractFormElementCaseEditorProvider.java b/designer_base/src/com/fr/design/fun/impl/AbstractFormElementCaseEditorProvider.java index f65107e2eb..bcd39d8f52 100644 --- a/designer_base/src/com/fr/design/fun/impl/AbstractFormElementCaseEditorProvider.java +++ b/designer_base/src/com/fr/design/fun/impl/AbstractFormElementCaseEditorProvider.java @@ -48,4 +48,12 @@ public abstract class AbstractFormElementCaseEditorProvider implements FormEleme public int getFitStateInPC(ReportFitAttrProvider fitAttrProvider) { return 0; } + + @Override + public boolean equals(Object obj) { + if(obj == null) { + return false; + } + return true; + } } \ No newline at end of file From f340f302ac47b8cecc9f5f9abe2843e89d41a7d4 Mon Sep 17 00:00:00 2001 From: PanLi320 <854954082@qq.com> Date: Thu, 3 Nov 2016 18:07:53 +0800 Subject: [PATCH 02/22] =?UTF-8?q?REPORT-745=20designer=5Fbase=E5=92=8Cform?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=E5=85=B3=E7=B3=BB=E5=86=85=E5=AE=B9=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fun/FormElementCaseEditorProvider.java | 9 +++---- ...AbstractFormElementCaseEditorProvider.java | 14 +++-------- .../design/designer/creator/XElementCase.java | 24 +++++++++++++++---- 3 files changed, 26 insertions(+), 21 deletions(-) diff --git a/designer_base/src/com/fr/design/fun/FormElementCaseEditorProvider.java b/designer_base/src/com/fr/design/fun/FormElementCaseEditorProvider.java index 191f7fa998..4ad5699fdd 100644 --- a/designer_base/src/com/fr/design/fun/FormElementCaseEditorProvider.java +++ b/designer_base/src/com/fr/design/fun/FormElementCaseEditorProvider.java @@ -1,11 +1,11 @@ package com.fr.design.fun; -import com.fr.form.ui.ElementCaseEditor; +import com.fr.stable.fun.IOFileAttrMark; import com.fr.stable.fun.ReportFitAttrProvider; -import com.fr.form.main.Form; import com.fr.stable.fun.mark.Mutable; import java.beans.PropertyDescriptor; +import java.util.Map; /** * Created by zhouping on 2015/9/10. @@ -16,10 +16,7 @@ public interface FormElementCaseEditorProvider extends Mutable { int CURRENT_LEVEL = 1; - - //加个provider返回tab的接口 - //design_base依赖了form - PropertyDescriptor[] createPropertyDescriptor (Class temp, Form form, ElementCaseEditor editor); + PropertyDescriptor[] createPropertyDescriptor (Class temp, Map attrMarkMap, ReportFitAttrProvider reportFitAttr); /** * 生成属性表 diff --git a/designer_base/src/com/fr/design/fun/impl/AbstractFormElementCaseEditorProvider.java b/designer_base/src/com/fr/design/fun/impl/AbstractFormElementCaseEditorProvider.java index bcd39d8f52..e6d4621aff 100644 --- a/designer_base/src/com/fr/design/fun/impl/AbstractFormElementCaseEditorProvider.java +++ b/designer_base/src/com/fr/design/fun/impl/AbstractFormElementCaseEditorProvider.java @@ -1,12 +1,12 @@ package com.fr.design.fun.impl; import com.fr.design.fun.FormElementCaseEditorProvider; -import com.fr.form.main.Form; -import com.fr.form.ui.ElementCaseEditor; +import com.fr.stable.fun.IOFileAttrMark; import com.fr.stable.fun.ReportFitAttrProvider; import com.fr.stable.fun.mark.API; import java.beans.PropertyDescriptor; +import java.util.Map; /** * Created by zhouping on 2015/9/10. @@ -24,7 +24,7 @@ public abstract class AbstractFormElementCaseEditorProvider implements FormEleme } @Override - public PropertyDescriptor[] createPropertyDescriptor(Class temp, Form reportAttr, ElementCaseEditor editor) { + public PropertyDescriptor[] createPropertyDescriptor(Class temp, Map attrMarkMap, ReportFitAttrProvider reportFitAttr) { return new PropertyDescriptor[0]; } @@ -48,12 +48,4 @@ public abstract class AbstractFormElementCaseEditorProvider implements FormEleme public int getFitStateInPC(ReportFitAttrProvider fitAttrProvider) { return 0; } - - @Override - public boolean equals(Object obj) { - if(obj == null) { - return false; - } - return true; - } } \ No newline at end of file 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 39caec435c..37919ead96 100644 --- a/designer_form/src/com/fr/design/designer/creator/XElementCase.java +++ b/designer_form/src/com/fr/design/designer/creator/XElementCase.java @@ -22,11 +22,13 @@ import com.fr.form.FormElementCaseContainerProvider; import com.fr.form.FormElementCaseProvider; import com.fr.form.ui.ElementCaseEditor; import com.fr.general.Inter; +import com.fr.plugin.ExtraClassManager; import com.fr.stable.ArrayUtils; import com.fr.stable.CoreGraphHelper; import com.fr.stable.core.PropertyChangeAdapter; -import com.fr.form.main.Form; +import com.fr.stable.fun.ExtraAttrMapProvider; import com.fr.stable.fun.FitProvider; +import com.fr.stable.fun.IOFileAttrMark; import com.fr.stable.fun.ReportFitAttrProvider; import javax.swing.*; @@ -100,7 +102,7 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme .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"), + .putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced") }; //这边有个插件兼容问题,之后还是要改回process才行 @@ -110,8 +112,22 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme continue; } this.designer = WidgetPropertyPane.getInstance().getEditingFormDesigner(); - Form form = designer.getTarget(); - PropertyDescriptor[] extraEditor = provider.createPropertyDescriptor(this.data.getClass(), form, this.toData()); + ElementCaseEditor editor = this.toData(); + Set setAttr = ExtraClassManager.getInstance().getArray(ExtraAttrMapProvider.XML_TAG); + for (ExtraAttrMapProvider attrProvider:setAttr) { + if (attrProvider == null) { + continue; + } + editor.addAttrMark((IOFileAttrMark) attrProvider); + } + FitProvider fitProvider = (FitProvider) designer.getTarget(); + ReportFitAttrProvider fitAttr = fitProvider.getFitAttr(); + //兼容之前报表块(之前三个选项为:默认 横向 双向 现在是:横向 双向 不自适应) + if (editor.getFitStateInPC() == 0) { + editor.setReportFitAttr(null); + } + ReportFitAttrProvider reportFitAttr = editor.getReportFitAttr() == null ? fitAttr : editor.getReportFitAttr(); + PropertyDescriptor[] extraEditor = provider.createPropertyDescriptor(this.data.getClass(), editor.getAttrMarkMap(), reportFitAttr); propertyTableEditor = (CRPropertyDescriptor[]) ArrayUtils.addAll(propertyTableEditor, extraEditor); } From 544538e412ffbf350861e1db9c9ec13675f66de3 Mon Sep 17 00:00:00 2001 From: PanLi320 <854954082@qq.com> Date: Thu, 3 Nov 2016 20:26:34 +0800 Subject: [PATCH 03/22] 1 1 --- .../com/fr/design/designer/creator/XElementCase.java | 10 ---------- 1 file changed, 10 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 37919ead96..b7ba2f65d9 100644 --- a/designer_form/src/com/fr/design/designer/creator/XElementCase.java +++ b/designer_form/src/com/fr/design/designer/creator/XElementCase.java @@ -22,13 +22,10 @@ import com.fr.form.FormElementCaseContainerProvider; import com.fr.form.FormElementCaseProvider; import com.fr.form.ui.ElementCaseEditor; import com.fr.general.Inter; -import com.fr.plugin.ExtraClassManager; import com.fr.stable.ArrayUtils; import com.fr.stable.CoreGraphHelper; import com.fr.stable.core.PropertyChangeAdapter; -import com.fr.stable.fun.ExtraAttrMapProvider; import com.fr.stable.fun.FitProvider; -import com.fr.stable.fun.IOFileAttrMark; import com.fr.stable.fun.ReportFitAttrProvider; import javax.swing.*; @@ -113,13 +110,6 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme } this.designer = WidgetPropertyPane.getInstance().getEditingFormDesigner(); ElementCaseEditor editor = this.toData(); - Set setAttr = ExtraClassManager.getInstance().getArray(ExtraAttrMapProvider.XML_TAG); - for (ExtraAttrMapProvider attrProvider:setAttr) { - if (attrProvider == null) { - continue; - } - editor.addAttrMark((IOFileAttrMark) attrProvider); - } FitProvider fitProvider = (FitProvider) designer.getTarget(); ReportFitAttrProvider fitAttr = fitProvider.getFitAttr(); //兼容之前报表块(之前三个选项为:默认 横向 双向 现在是:横向 双向 不自适应) From eb9f159c3f3fcd879384ecd0dcb7cc196e0c0bfa Mon Sep 17 00:00:00 2001 From: daniel Date: Fri, 4 Nov 2016 13:22:40 +0800 Subject: [PATCH 04/22] log --- designer_base/src/com/fr/start/BaseDesigner.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer_base/src/com/fr/start/BaseDesigner.java b/designer_base/src/com/fr/start/BaseDesigner.java index 9e25a76c68..af8067ae53 100644 --- a/designer_base/src/com/fr/start/BaseDesigner.java +++ b/designer_base/src/com/fr/start/BaseDesigner.java @@ -248,7 +248,7 @@ public abstract class BaseDesigner extends ToolBarMenuDock { }); df.setVisible(true); } catch (Exception e) { - FRLogger.getLogger().error(e.getMessage()); + FRLogger.getLogger().error(e.getMessage(), e); if (!isException) { showDesignerFrame(args, df, true); } else { From 6f5a6915b24575e0b70ba27f24e790cd564bacd4 Mon Sep 17 00:00:00 2001 From: daniel Date: Fri, 4 Nov 2016 13:24:30 +0800 Subject: [PATCH 05/22] change --- ...umnEditor.java => CellDSColumnEditor.java} | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) rename designer/src/com/fr/quickeditor/cellquick/{CellDScolumnEditor.java => CellDSColumnEditor.java} (90%) diff --git a/designer/src/com/fr/quickeditor/cellquick/CellDScolumnEditor.java b/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java similarity index 90% rename from designer/src/com/fr/quickeditor/cellquick/CellDScolumnEditor.java rename to designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java index f92b353943..11cea3e152 100644 --- a/designer/src/com/fr/quickeditor/cellquick/CellDScolumnEditor.java +++ b/designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java @@ -16,7 +16,7 @@ import java.awt.*; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; -public class CellDScolumnEditor extends CellQuickEditor { +public class CellDSColumnEditor extends CellQuickEditor { private JPanel dsColumnRegion; private JPanel centerPane; private SelectedDataColumnPane dataPane; @@ -55,16 +55,7 @@ public class CellDScolumnEditor extends CellQuickEditor { } }; - private static CellDScolumnEditor THIS; - - public static final CellDScolumnEditor getInstance() { - if (THIS == null) { - THIS = new CellDScolumnEditor(); - } - return THIS; - } - - private CellDScolumnEditor() { + private CellDSColumnEditor() { super(); } @@ -107,4 +98,14 @@ public class CellDScolumnEditor extends CellQuickEditor { this.validate(); } + + /** + * for 关闭时候释放 + */ + public void release () { + super.release(); + dsColumnRegion = null; + centerPane = null; + } + } \ No newline at end of file From 375bb008717ee5dd6dc5d86beeeab645920e7327 Mon Sep 17 00:00:00 2001 From: zhouping Date: Fri, 4 Nov 2016 13:50:11 +0800 Subject: [PATCH 06/22] =?UTF-8?q?=E6=97=A0JIRA=E4=BB=BB=E5=8A=A1=20dev?= =?UTF-8?q?=E8=A2=AB=E8=A6=86=E7=9B=96=E7=9A=84=E4=BB=A3=E7=A0=81=E8=BF=98?= =?UTF-8?q?=E5=8E=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../properties/FRAbsoluteBodyLayoutPropertiesGroupModel.java | 3 --- .../design/designer/properties/items/FRLayoutTypeItems.java | 4 ++-- .../src/com/fr/design/gui/core/FormWidgetOption.java | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/designer_form/src/com/fr/design/designer/properties/FRAbsoluteBodyLayoutPropertiesGroupModel.java b/designer_form/src/com/fr/design/designer/properties/FRAbsoluteBodyLayoutPropertiesGroupModel.java index ab22986161..6b29a172e5 100644 --- a/designer_form/src/com/fr/design/designer/properties/FRAbsoluteBodyLayoutPropertiesGroupModel.java +++ b/designer_form/src/com/fr/design/designer/properties/FRAbsoluteBodyLayoutPropertiesGroupModel.java @@ -116,9 +116,6 @@ public class FRAbsoluteBodyLayoutPropertiesGroupModel extends FRAbsoluteLayoutPr moveComponents2FitLayout(xfl); FormDesigner formDesigner = WidgetPropertyPane.getInstance().getEditingFormDesigner(); formDesigner.getSelectionModel().setSelectedCreator(xfl); - xfl.convert(); - LayoutUtils.layoutContainer(xfl); - xfl.adjustCreatorsWhileSlide(xfl.getContainerPercent() - 1.0); for (int i = 0; i < components.length; i++) { Component comp = xfl.getComponent(i); diff --git a/designer_form/src/com/fr/design/designer/properties/items/FRLayoutTypeItems.java b/designer_form/src/com/fr/design/designer/properties/items/FRLayoutTypeItems.java index cd9ddb439c..a19d975170 100644 --- a/designer_form/src/com/fr/design/designer/properties/items/FRLayoutTypeItems.java +++ b/designer_form/src/com/fr/design/designer/properties/items/FRLayoutTypeItems.java @@ -7,8 +7,8 @@ import com.fr.form.ui.container.WBodyLayoutType; */ public class FRLayoutTypeItems implements ItemProvider{ public static final Item[] ITEMS = new Item[] { - new Item(WBodyLayoutType.FIT.description(), WBodyLayoutType.FIT.getTypeValue())/*, - new Item(WBodyLayoutType.ABSOLUTE.description(), WBodyLayoutType.ABSOLUTE.getTypeValue())*/}; + new Item(WBodyLayoutType.FIT.description(), WBodyLayoutType.FIT.getTypeValue()), + new Item(WBodyLayoutType.ABSOLUTE.description(), WBodyLayoutType.ABSOLUTE.getTypeValue())}; public Item[] getItems() { return ITEMS; diff --git a/designer_form/src/com/fr/design/gui/core/FormWidgetOption.java b/designer_form/src/com/fr/design/gui/core/FormWidgetOption.java index 545ffadf73..b3fa73a26d 100644 --- a/designer_form/src/com/fr/design/gui/core/FormWidgetOption.java +++ b/designer_form/src/com/fr/design/gui/core/FormWidgetOption.java @@ -1 +1 @@ -package com.fr.design.gui.core; import javax.swing.Icon; import com.fr.base.BaseUtils; import com.fr.form.ui.ElementCaseEditor; import com.fr.form.ui.Widget; import com.fr.form.ui.container.WAbsoluteLayout; import com.fr.form.ui.container.WBorderLayout; import com.fr.form.ui.container.WCardLayout; import com.fr.form.ui.container.WFitLayout; import com.fr.form.ui.container.WHorizontalBoxLayout; import com.fr.form.ui.container.WParameterLayout; import com.fr.form.ui.container.WVerticalBoxLayout; import com.fr.general.Inter; /** * Author : Shockway * Date: 13-6-17 * Time: 上午10:40 */ public class FormWidgetOption extends WidgetOption { /** * 返回名字 * @return 名字 */ @Override public String optionName() { return null; } /** * 返回图标 * @return 图标 */ @Override public Icon optionIcon() { return null; } /** * 组件类 * @return 类 */ @Override public Class widgetClass() { return null; } /** * 返回组件 * @return 控件 */ @Override public Widget createWidget() { return null; } /* * 表单容器 */ public static WidgetOption[] getFormContainerInstance() { return new WidgetOption[] { ABSOLUTELAYOUTCONTAINER, BORDERLAYOUTCONTAINER, HORIZONTALBOXLAYOUTCONTAINER, VERTICALBOXLAYOUTCONTAINER, CARDLAYOUTCONTAINER, FITLAYOUTCONTAINER }; } /** * 表单工具栏上的布局 * @return 控件 */ public static WidgetOption[] getFormLayoutInstance() { return new WidgetOption[] {CARDLAYOUTCONTAINER/*, ABSOLUTELAYOUTCONTAINER*/}; } public static final WidgetOption ABSOLUTELAYOUTCONTAINER = WidgetOptionFactory.createByWidgetClass(Inter .getLocText("FR-Designer_Layout_Block_Absolute"), BaseUtils.readIcon("/com/fr/web/images/form/resources/layout_absolute_new.png"), WAbsoluteLayout.class); public static final WidgetOption BORDERLAYOUTCONTAINER = WidgetOptionFactory.createByWidgetClass(Inter .getLocText("FR-Designer_BorderLayout"), BaseUtils.readIcon("/com/fr/web/images/form/resources/layout_border.png"), WBorderLayout.class); public static final WidgetOption CARDLAYOUTCONTAINER = WidgetOptionFactory.createByWidgetClass(Inter .getLocText("FR-Designer_Layout_Block_Tab"), BaseUtils.readIcon("/com/fr/web/images/form/resources/card_layout_16.png"), WCardLayout.class); public static final WidgetOption HORIZONTALBOXLAYOUTCONTAINER = WidgetOptionFactory.createByWidgetClass(Inter .getLocText("FR-Designer_Layout-HBox"), BaseUtils.readIcon("/com/fr/web/images/form/resources/boxlayout_h_16.png"), WHorizontalBoxLayout.class); public static final WidgetOption VERTICALBOXLAYOUTCONTAINER = WidgetOptionFactory.createByWidgetClass(Inter .getLocText("FR-Designer_VerticalBoxLayout"), BaseUtils.readIcon("/com/fr/web/images/form/resources/boxlayout_v_16.png"), WVerticalBoxLayout.class); public static final WidgetOption FITLAYOUTCONTAINER = WidgetOptionFactory.createByWidgetClass(Inter.getLocText("FR-Designer-Layout_Adaptive_Layout"), BaseUtils.readIcon("/com/fr/web/images/form/resources/boxlayout_v_16.png"), WFitLayout.class); public static final WidgetOption PARAMETERCONTAINER = WidgetOptionFactory.createByWidgetClass(Inter .getLocText("FR-Designer_Para-Body"), BaseUtils.readIcon("/com/fr/web/images/form/resources/layout_parameter.png"), WParameterLayout.class); public static final WidgetOption ELEMENTCASE = WidgetOptionFactory.createByWidgetClass(Inter .getLocText("FR-Designer_Form-Report"), BaseUtils.readIcon("/com/fr/web/images/form/resources/report_16.png"), ElementCaseEditor.class); } \ No newline at end of file +package com.fr.design.gui.core; import javax.swing.Icon; import com.fr.base.BaseUtils; import com.fr.form.ui.ElementCaseEditor; import com.fr.form.ui.Widget; import com.fr.form.ui.container.WAbsoluteLayout; import com.fr.form.ui.container.WBorderLayout; import com.fr.form.ui.container.WCardLayout; import com.fr.form.ui.container.WFitLayout; import com.fr.form.ui.container.WHorizontalBoxLayout; import com.fr.form.ui.container.WParameterLayout; import com.fr.form.ui.container.WVerticalBoxLayout; import com.fr.general.Inter; /** * Author : Shockway * Date: 13-6-17 * Time: 上午10:40 */ public class FormWidgetOption extends WidgetOption { /** * 返回名字 * @return 名字 */ @Override public String optionName() { return null; } /** * 返回图标 * @return 图标 */ @Override public Icon optionIcon() { return null; } /** * 组件类 * @return 类 */ @Override public Class widgetClass() { return null; } /** * 返回组件 * @return 控件 */ @Override public Widget createWidget() { return null; } /* * 表单容器 */ public static WidgetOption[] getFormContainerInstance() { return new WidgetOption[] { ABSOLUTELAYOUTCONTAINER, BORDERLAYOUTCONTAINER, HORIZONTALBOXLAYOUTCONTAINER, VERTICALBOXLAYOUTCONTAINER, CARDLAYOUTCONTAINER, FITLAYOUTCONTAINER }; } /** * 表单工具栏上的布局 * @return 控件 */ public static WidgetOption[] getFormLayoutInstance() { return new WidgetOption[] {CARDLAYOUTCONTAINER, ABSOLUTELAYOUTCONTAINER}; } public static final WidgetOption ABSOLUTELAYOUTCONTAINER = WidgetOptionFactory.createByWidgetClass(Inter .getLocText("FR-Designer_Layout_Block_Absolute"), BaseUtils.readIcon("/com/fr/web/images/form/resources/layout_absolute_new.png"), WAbsoluteLayout.class); public static final WidgetOption BORDERLAYOUTCONTAINER = WidgetOptionFactory.createByWidgetClass(Inter .getLocText("FR-Designer_BorderLayout"), BaseUtils.readIcon("/com/fr/web/images/form/resources/layout_border.png"), WBorderLayout.class); public static final WidgetOption CARDLAYOUTCONTAINER = WidgetOptionFactory.createByWidgetClass(Inter .getLocText("FR-Designer_Layout_Block_Tab"), BaseUtils.readIcon("/com/fr/web/images/form/resources/card_layout_16.png"), WCardLayout.class); public static final WidgetOption HORIZONTALBOXLAYOUTCONTAINER = WidgetOptionFactory.createByWidgetClass(Inter .getLocText("FR-Designer_Layout-HBox"), BaseUtils.readIcon("/com/fr/web/images/form/resources/boxlayout_h_16.png"), WHorizontalBoxLayout.class); public static final WidgetOption VERTICALBOXLAYOUTCONTAINER = WidgetOptionFactory.createByWidgetClass(Inter .getLocText("FR-Designer_VerticalBoxLayout"), BaseUtils.readIcon("/com/fr/web/images/form/resources/boxlayout_v_16.png"), WVerticalBoxLayout.class); public static final WidgetOption FITLAYOUTCONTAINER = WidgetOptionFactory.createByWidgetClass(Inter.getLocText("FR-Designer-Layout_Adaptive_Layout"), BaseUtils.readIcon("/com/fr/web/images/form/resources/boxlayout_v_16.png"), WFitLayout.class); public static final WidgetOption PARAMETERCONTAINER = WidgetOptionFactory.createByWidgetClass(Inter .getLocText("FR-Designer_Para-Body"), BaseUtils.readIcon("/com/fr/web/images/form/resources/layout_parameter.png"), WParameterLayout.class); public static final WidgetOption ELEMENTCASE = WidgetOptionFactory.createByWidgetClass(Inter .getLocText("FR-Designer_Form-Report"), BaseUtils.readIcon("/com/fr/web/images/form/resources/report_16.png"), ElementCaseEditor.class); } \ No newline at end of file From b638168388be417717ef6d1514a9944141cd0374 Mon Sep 17 00:00:00 2001 From: PanLi320 <854954082@qq.com> Date: Fri, 4 Nov 2016 16:45:24 +0800 Subject: [PATCH 07/22] =?UTF-8?q?REPORT-745=20designer=5Fbase=E5=92=8Cform?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=E5=85=B3=E7=B3=BB=E5=86=85=E5=AE=B9=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/fun/FormElementCaseEditorProvider.java | 6 +++--- .../AbstractFormElementCaseEditorProvider.java | 7 +++---- .../fr/design/designer/creator/XElementCase.java | 14 +++++--------- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/designer_base/src/com/fr/design/fun/FormElementCaseEditorProvider.java b/designer_base/src/com/fr/design/fun/FormElementCaseEditorProvider.java index 4ad5699fdd..92a1a835f4 100644 --- a/designer_base/src/com/fr/design/fun/FormElementCaseEditorProvider.java +++ b/designer_base/src/com/fr/design/fun/FormElementCaseEditorProvider.java @@ -1,11 +1,11 @@ package com.fr.design.fun; -import com.fr.stable.fun.IOFileAttrMark; +import com.fr.form.FormProvider; +import com.fr.form.ui.ElementCaseEditorProvider; import com.fr.stable.fun.ReportFitAttrProvider; import com.fr.stable.fun.mark.Mutable; import java.beans.PropertyDescriptor; -import java.util.Map; /** * Created by zhouping on 2015/9/10. @@ -16,7 +16,7 @@ public interface FormElementCaseEditorProvider extends Mutable { int CURRENT_LEVEL = 1; - PropertyDescriptor[] createPropertyDescriptor (Class temp, Map attrMarkMap, ReportFitAttrProvider reportFitAttr); + PropertyDescriptor[] createPropertyDescriptor(Class temp, FormProvider formProvider, ElementCaseEditorProvider editor); /** * 生成属性表 diff --git a/designer_base/src/com/fr/design/fun/impl/AbstractFormElementCaseEditorProvider.java b/designer_base/src/com/fr/design/fun/impl/AbstractFormElementCaseEditorProvider.java index e6d4621aff..c3cdbaa422 100644 --- a/designer_base/src/com/fr/design/fun/impl/AbstractFormElementCaseEditorProvider.java +++ b/designer_base/src/com/fr/design/fun/impl/AbstractFormElementCaseEditorProvider.java @@ -1,12 +1,12 @@ package com.fr.design.fun.impl; import com.fr.design.fun.FormElementCaseEditorProvider; -import com.fr.stable.fun.IOFileAttrMark; +import com.fr.form.FormProvider; +import com.fr.form.ui.ElementCaseEditorProvider; import com.fr.stable.fun.ReportFitAttrProvider; import com.fr.stable.fun.mark.API; import java.beans.PropertyDescriptor; -import java.util.Map; /** * Created by zhouping on 2015/9/10. @@ -23,8 +23,7 @@ public abstract class AbstractFormElementCaseEditorProvider implements FormEleme return this.getClass().getName(); } - @Override - public PropertyDescriptor[] createPropertyDescriptor(Class temp, Map attrMarkMap, ReportFitAttrProvider reportFitAttr) { + public PropertyDescriptor[] createPropertyDescriptor(Class temp, FormProvider reportAttr, ElementCaseEditorProvider editor) { return new PropertyDescriptor[0]; } 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 b7ba2f65d9..5d161969bf 100644 --- a/designer_form/src/com/fr/design/designer/creator/XElementCase.java +++ b/designer_form/src/com/fr/design/designer/creator/XElementCase.java @@ -20,7 +20,9 @@ import com.fr.design.mainframe.widget.renderer.LayoutBorderStyleRenderer; import com.fr.design.mainframe.widget.renderer.PaddingMarginCellRenderer; import com.fr.form.FormElementCaseContainerProvider; import com.fr.form.FormElementCaseProvider; +import com.fr.form.FormProvider; import com.fr.form.ui.ElementCaseEditor; +import com.fr.form.ui.ElementCaseEditorProvider; import com.fr.general.Inter; import com.fr.stable.ArrayUtils; import com.fr.stable.CoreGraphHelper; @@ -109,15 +111,9 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme continue; } this.designer = WidgetPropertyPane.getInstance().getEditingFormDesigner(); - ElementCaseEditor editor = this.toData(); - FitProvider fitProvider = (FitProvider) designer.getTarget(); - ReportFitAttrProvider fitAttr = fitProvider.getFitAttr(); - //兼容之前报表块(之前三个选项为:默认 横向 双向 现在是:横向 双向 不自适应) - if (editor.getFitStateInPC() == 0) { - editor.setReportFitAttr(null); - } - ReportFitAttrProvider reportFitAttr = editor.getReportFitAttr() == null ? fitAttr : editor.getReportFitAttr(); - PropertyDescriptor[] extraEditor = provider.createPropertyDescriptor(this.data.getClass(), editor.getAttrMarkMap(), reportFitAttr); + FormProvider formProvider = designer.getTarget(); + ElementCaseEditorProvider elementCaseEditorProvider = this.toData(); + PropertyDescriptor[] extraEditor = provider.createPropertyDescriptor(this.data.getClass(), formProvider, elementCaseEditorProvider); propertyTableEditor = (CRPropertyDescriptor[]) ArrayUtils.addAll(propertyTableEditor, extraEditor); } From 9bfce25c0aac31f39fb3a92de81645c420f42425 Mon Sep 17 00:00:00 2001 From: PanLi320 <854954082@qq.com> Date: Fri, 4 Nov 2016 16:47:02 +0800 Subject: [PATCH 08/22] 1 --- .../design/fun/impl/AbstractFormElementCaseEditorProvider.java | 1 + 1 file changed, 1 insertion(+) diff --git a/designer_base/src/com/fr/design/fun/impl/AbstractFormElementCaseEditorProvider.java b/designer_base/src/com/fr/design/fun/impl/AbstractFormElementCaseEditorProvider.java index c3cdbaa422..8764eaf898 100644 --- a/designer_base/src/com/fr/design/fun/impl/AbstractFormElementCaseEditorProvider.java +++ b/designer_base/src/com/fr/design/fun/impl/AbstractFormElementCaseEditorProvider.java @@ -23,6 +23,7 @@ public abstract class AbstractFormElementCaseEditorProvider implements FormEleme return this.getClass().getName(); } + @Override public PropertyDescriptor[] createPropertyDescriptor(Class temp, FormProvider reportAttr, ElementCaseEditorProvider editor) { return new PropertyDescriptor[0]; } From da81437dc1d6a472cf910a8fc138db69a0cdca6d Mon Sep 17 00:00:00 2001 From: Fangjie Hu Date: Sun, 6 Nov 2016 16:51:38 +0800 Subject: [PATCH 09/22] =?UTF-8?q?=E5=9B=BE=E6=A0=87=E5=88=87=E6=8D=A2?= =?UTF-8?q?=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chart/gui/ChartTypeButtonPane.java | 2 ++ .../mainframe/chart/gui/ChartTypePane.java | 32 ++++++++++++++++--- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java b/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java index f9c6e572c6..786b3d1bda 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java @@ -283,6 +283,8 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen private void changeCollectionSelected(String name) { if (editingCollection != null) { + //图表切换事件生效 + editingCollection.setChangeEvent(true); int count = editingCollection.getChartCount(); for (int i = 0; i < count; i++) { if (ComparatorUtils.equals(name, editingCollection.getChartName(i))) { diff --git a/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypePane.java b/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypePane.java index bd63724e1b..5b55562152 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypePane.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypePane.java @@ -8,7 +8,6 @@ import com.fr.chart.chartattr.SwitchState; import com.fr.chart.charttypes.ChartTypeManager; import com.fr.design.ChartTypeInterfaceManager; import com.fr.design.beans.FurtherBasicBeanPane; -import com.fr.design.chart.fun.IndependentChartUIProvider; import com.fr.design.dialog.BasicScrollPane; import com.fr.design.gui.frpane.UIComboBoxPane; import com.fr.design.gui.icombobox.UIComboBox; @@ -45,6 +44,8 @@ public class ChartTypePane extends AbstractChartAttrPane{ private SwitchState paneState = SwitchState.DEFAULT; //记录当前面板是谁在使用切换状态 private String chartID = StringUtils.EMPTY; + //记录当前面板是否处在图表切换的事件状态 + private boolean isChangEvent = false; public SwitchState getPaneState() { return paneState; @@ -61,6 +62,17 @@ public class ChartTypePane extends AbstractChartAttrPane{ public void setChartID(String chartID) { this.chartID = chartID; } + + //使用一次即失效 + public boolean useChangEvent() { + boolean event = isChangEvent; + isChangEvent = false; + return event; + } + + public void setChangEvent(boolean changEvent) { + isChangEvent = changEvent; + } } @Override @@ -127,7 +139,13 @@ public class ChartTypePane extends AbstractChartAttrPane{ protected String title4PopupWindow() { return null; } - + + /** + * 不同图表切换分同一个selected的不同图表切换和不同selected的不同图表切换 + * 如果是切换图表的某个图表发生变化,则collection的选择下标不会变 + * 如果是切换图表的不同图表之间切换,则collection的选择下标会改变 + * @param chart + */ public void updateBean(Chart chart) { Plot oldPlot = chart.getPlot(); @@ -161,9 +179,12 @@ public class ChartTypePane extends AbstractChartAttrPane{ boolean isUseDefault = ChartTypeInterfaceManager.getInstance().isUseDefaultPane(plotID); - if(editPane.isDefaultPane() != isUseDefault || (!isUseDefault && !ComparatorUtils.equals(lastPlotID, plotID))){ + if(editPane.isDefaultPane() != isUseDefault || (!isUseDefault && !ComparatorUtils.equals(lastPlotID, plotID)) || paneState.useChangEvent()){ editPane.reLayout(chart); } + + //重置面板切换事件状态 + paneState.setChangEvent(false); } } @@ -291,7 +312,10 @@ public class ChartTypePane extends AbstractChartAttrPane{ editingCollection = collection; buttonPane.update(collection);// 内部操作时 已经做过处理. Chart chart = collection.getSelectedChart(); - + //判断是否是图表切换事件 + if (collection.useChangeEvent()){ + paneState.setChangEvent(true); + } chartTypePane.updateBean(chart); } From 7437f96267eec11191f5d5a77f65a8ae32667ee6 Mon Sep 17 00:00:00 2001 From: juhaoyu <2335173323@qq.com> Date: Mon, 7 Nov 2016 09:56:50 +0800 Subject: [PATCH 10/22] =?UTF-8?q?=E5=86=8Ddev=E4=B8=AD=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E4=B8=8B=E6=8B=89=E6=A0=91=E6=9E=81=E9=80=9F=E6=9E=84=E5=BB=BA?= =?UTF-8?q?=EF=BC=88=E4=B9=8B=E5=89=8Dmaster=E5=9B=9E=E9=80=80=E4=B9=8B?= =?UTF-8?q?=E5=90=8E=EF=BC=8C=E5=8F=88=E8=87=AA=E5=8A=A8=E6=8A=8Adev?= =?UTF-8?q?=E5=9B=9E=E9=80=80=E4=BA=86=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/gui/frpane/TreeSettingPane.java | 79 ++++++++++++++----- 1 file changed, 59 insertions(+), 20 deletions(-) diff --git a/designer_base/src/com/fr/design/gui/frpane/TreeSettingPane.java b/designer_base/src/com/fr/design/gui/frpane/TreeSettingPane.java index f0a94f3050..65df6f0625 100644 --- a/designer_base/src/com/fr/design/gui/frpane/TreeSettingPane.java +++ b/designer_base/src/com/fr/design/gui/frpane/TreeSettingPane.java @@ -1,40 +1,48 @@ package com.fr.design.gui.frpane; -import java.awt.BorderLayout; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; - -import com.fr.data.impl.TreeNodeWrapper; -import com.fr.design.data.DataCreatorUI; -import com.fr.design.gui.ilable.UILabel; - -import javax.swing.*; - -import com.fr.general.NameObject; import com.fr.data.impl.TableDataDictionary; import com.fr.data.impl.TreeAttr; import com.fr.data.impl.TreeNodeAttr; +import com.fr.data.impl.TreeNodeWrapper; +import com.fr.design.data.DataCreatorUI; +import com.fr.design.dialog.BasicPane; import com.fr.design.gui.controlpane.NameObjectCreator; import com.fr.design.gui.controlpane.NameableCreator; +import com.fr.design.gui.frpane.tree.layer.config.LayerDataControlPane; import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itree.refreshabletree.TreeDataCardPane; import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.dialog.BasicPane; import com.fr.form.ui.TreeComboBoxEditor; import com.fr.form.ui.TreeEditor; +import com.fr.form.ui.tree.LayerConfig; import com.fr.general.Inter; +import com.fr.general.NameObject; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; public class TreeSettingPane extends BasicPane implements DataCreatorUI { private JTreeControlPane controlPane; + private JTreeAutoBuildPane autoBuildPane; + + /** + * 新的分层构建方式 + */ + private LayerDataControlPane layerDataControlPane; + private UIComboBox buildBox; + /** * */ private static final long serialVersionUID = 1762889323082827111L; - private String[] buildWay = new String[] { Inter.getLocText("FR-Designer_Layer-Build"), - Inter.getLocText("FR-Designer_Auto-Build") }; + private String[] buildWay = new String[]{Inter.getLocText("FR-Designer_DataTable-Build"), + Inter.getLocText("FR-Designer_Auto-Build"), Inter.getLocText("FR-Designer_Layer-Build")}; public TreeSettingPane(boolean isEditor) { this.initComponents(isEditor); @@ -58,14 +66,30 @@ public class TreeSettingPane extends BasicPane implements DataCreatorUI { controlPane = new JTreeControlPane(new NameableCreator[] { treeNode }, new TreeDataCardPane(), isEditor); autoBuildPane = new JTreeAutoBuildPane(); + layerDataControlPane = new LayerDataControlPane(); this.add(buildWayPanel, BorderLayout.NORTH); cardChanged(0); } private void cardChanged(int index) { + this.remove(controlPane); this.remove(autoBuildPane); - this.add(index == 0 ? controlPane : autoBuildPane, BorderLayout.CENTER); + this.remove(layerDataControlPane); + switch (index) { + case 0: + this.add(layerDataControlPane); + break; + case 1: + this.add(autoBuildPane); + break; + case 2: + this.add(controlPane); + + break; + default: + break; + } validate(); repaint(); revalidate(); @@ -101,8 +125,17 @@ public class TreeSettingPane extends BasicPane implements DataCreatorUI { buildBox.setSelectedIndex(1); TableDataDictionary dictionary = treeEditor.getDictionary(); autoBuildPane.populate(dictionary); - } else { + } else if (treeEditor.isLayerBuild()) { buildBox.setSelectedIndex(0); + java.util.List layerConfigList = treeEditor.getLayerConfigs(); + LayerConfig[] layerConfigs = new LayerConfig[layerConfigList.size()]; + int i = 0; + for (LayerConfig layerConfig : layerConfigList) { + layerConfigs[i++] = layerConfig; + } + this.layerDataControlPane.populate(new NameObject("tree", layerConfigs)); + } else { + buildBox.setSelectedIndex(2); } } @@ -123,7 +156,7 @@ public class TreeSettingPane extends BasicPane implements DataCreatorUI { te.setAutoBuild(true); te.setDictionary(dictionary); te.setNodeOrDict(dictionary); - } else { + } else if (buildBox.getSelectedIndex() == 2) { te.setAutoBuild(false); NameObject no = this.controlPane.update(); if (no != null) { @@ -150,11 +183,14 @@ public class TreeSettingPane extends BasicPane implements DataCreatorUI { * @return */ public Object updateTreeNodeAttrs() { - if(buildBox.getSelectedIndex() == 0) { + + if (buildBox.getSelectedIndex() == 2) { NameObject no = controlPane.update(); if (no != null) { return no.getObject(); } + } else if (buildBox.getSelectedIndex() == 0) { + return layerDataControlPane.update(); } else { return autoBuildPane.update(); } @@ -172,7 +208,7 @@ public class TreeSettingPane extends BasicPane implements DataCreatorUI { tcb.setAutoBuild(true); tcb.setDictionary(dictionary); tcb.setNodeOrDict(dictionary); - } else { + } else if (buildBox.getSelectedIndex() == 2) { tcb.setAutoBuild(false); NameObject no = this.controlPane.update(); if (no != null) { @@ -204,12 +240,15 @@ public class TreeSettingPane extends BasicPane implements DataCreatorUI { */ public void populate(Object nodeOrDict) { if(nodeOrDict instanceof TreeNodeAttr[] || nodeOrDict instanceof TreeNodeWrapper) { - buildBox.setSelectedIndex(0); + buildBox.setSelectedIndex(2); NameObject no = new NameObject("name", nodeOrDict); controlPane.populate(no); } else if(nodeOrDict instanceof TableDataDictionary) { buildBox.setSelectedIndex(1); autoBuildPane.populate((TableDataDictionary)nodeOrDict); + } else if (nodeOrDict instanceof NameObject) { + buildBox.setSelectedIndex(0); + layerDataControlPane.populate((NameObject) nodeOrDict); } } } \ No newline at end of file From 1a6500d1a4a906f095ab43b95f5f4343089d988e Mon Sep 17 00:00:00 2001 From: Fangjie Hu Date: Mon, 7 Nov 2016 14:15:51 +0800 Subject: [PATCH 11/22] =?UTF-8?q?=E9=9D=A2=E6=9D=BF=E9=87=8D=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/chart/gui/ChartComponent.java | 2 +- .../chart/gui/ChartTypeButtonPane.java | 6 ++-- .../mainframe/chart/gui/ChartTypePane.java | 32 +++++++------------ 3 files changed, 16 insertions(+), 24 deletions(-) diff --git a/designer_chart/src/com/fr/design/chart/gui/ChartComponent.java b/designer_chart/src/com/fr/design/chart/gui/ChartComponent.java index 8565135629..5ce350450b 100644 --- a/designer_chart/src/com/fr/design/chart/gui/ChartComponent.java +++ b/designer_chart/src/com/fr/design/chart/gui/ChartComponent.java @@ -315,7 +315,7 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene //不直接画chartGlyph而画image的原因是表单的柱形图会溢出表单 //其他图都ok,其实感觉应该是柱形图画的不对,应该也可以改那边 //处理画图事件 - Image chartImage = chartGlyph.toImage(chartWidth,chartHeight,ScreenResolution.getScreenResolution(), this); + Image chartImage = chartGlyph.toImage(chartWidth,chartHeight,ScreenResolution.getScreenResolution(), this, null); g2d.drawImage(chartImage, 0, 0, null); } } diff --git a/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java b/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java index 786b3d1bda..49e64385e6 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java @@ -283,12 +283,14 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen private void changeCollectionSelected(String name) { if (editingCollection != null) { - //图表切换事件生效 - editingCollection.setChangeEvent(true); int count = editingCollection.getChartCount(); for (int i = 0; i < count; i++) { if (ComparatorUtils.equals(name, editingCollection.getChartName(i))) { editingCollection.setSelectedIndex(i); + //重构面板 + if (parent != null){ + parent.relayOutEditPane(editingCollection.getSelectedChart()); + } break; } } diff --git a/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypePane.java b/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypePane.java index 5b55562152..6d6635b1eb 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypePane.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypePane.java @@ -44,8 +44,6 @@ public class ChartTypePane extends AbstractChartAttrPane{ private SwitchState paneState = SwitchState.DEFAULT; //记录当前面板是谁在使用切换状态 private String chartID = StringUtils.EMPTY; - //记录当前面板是否处在图表切换的事件状态 - private boolean isChangEvent = false; public SwitchState getPaneState() { return paneState; @@ -62,17 +60,6 @@ public class ChartTypePane extends AbstractChartAttrPane{ public void setChartID(String chartID) { this.chartID = chartID; } - - //使用一次即失效 - public boolean useChangEvent() { - boolean event = isChangEvent; - isChangEvent = false; - return event; - } - - public void setChangEvent(boolean changEvent) { - isChangEvent = changEvent; - } } @Override @@ -179,12 +166,9 @@ public class ChartTypePane extends AbstractChartAttrPane{ boolean isUseDefault = ChartTypeInterfaceManager.getInstance().isUseDefaultPane(plotID); - if(editPane.isDefaultPane() != isUseDefault || (!isUseDefault && !ComparatorUtils.equals(lastPlotID, plotID)) || paneState.useChangEvent()){ + if(editPane.isDefaultPane() != isUseDefault || (!isUseDefault && !ComparatorUtils.equals(lastPlotID, plotID))){ editPane.reLayout(chart); } - - //重置面板切换事件状态 - paneState.setChangEvent(false); } } @@ -278,6 +262,16 @@ public class ChartTypePane extends AbstractChartAttrPane{ } + /** + * 重构面板 + * @param chart + */ + public void relayOutEditPane(Chart chart){ + if (editPane != null){ + editPane.reLayout(chart); + } + } + public void reactorChartTypePane(ChartCollection collection){ if (needReactor(collection)) { @@ -312,10 +306,6 @@ public class ChartTypePane extends AbstractChartAttrPane{ editingCollection = collection; buttonPane.update(collection);// 内部操作时 已经做过处理. Chart chart = collection.getSelectedChart(); - //判断是否是图表切换事件 - if (collection.useChangeEvent()){ - paneState.setChangEvent(true); - } chartTypePane.updateBean(chart); } From c153cdc433b3817e43f9ae774e953072bc2659ea Mon Sep 17 00:00:00 2001 From: Fangjie Hu Date: Mon, 7 Nov 2016 14:19:18 +0800 Subject: [PATCH 12/22] update --- .../com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java | 2 +- .../src/com/fr/design/mainframe/chart/gui/ChartTypePane.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java b/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java index 49e64385e6..46722836af 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java @@ -289,7 +289,7 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen editingCollection.setSelectedIndex(i); //重构面板 if (parent != null){ - parent.relayOutEditPane(editingCollection.getSelectedChart()); + parent.reLayoutEditPane(editingCollection.getSelectedChart()); } break; } diff --git a/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypePane.java b/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypePane.java index 6d6635b1eb..a286b39c8c 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypePane.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypePane.java @@ -266,7 +266,7 @@ public class ChartTypePane extends AbstractChartAttrPane{ * 重构面板 * @param chart */ - public void relayOutEditPane(Chart chart){ + public void reLayoutEditPane(Chart chart){ if (editPane != null){ editPane.reLayout(chart); } From 51e95ad3aa6e0aac9f846b6380136dedb9f669dd Mon Sep 17 00:00:00 2001 From: daniel Date: Mon, 7 Nov 2016 14:26:00 +0800 Subject: [PATCH 13/22] =?UTF-8?q?=E5=86=85=E5=AD=98=E9=87=8A=E6=94=BE?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/module/DesignerModule.java | 33 +- .../fr/poly/creator/ChartBlockCreator.java | 2 +- .../com/fr/quickeditor/CellQuickEditor.java | 2 +- .../com/fr/quickeditor/ChartQuickEditor.java | 18 +- .../fr/design/actions/core/ActionFactory.java | 36 +- .../design/actions/file/SwitchExistEnv.java | 16 +- .../design/data/DesignTableDataManager.java | 44 +- .../data/datapane/TableDataComboBox.java | 1 + .../design/event/TemplateTreeDragSource.java | 37 -- .../design/file/HistoryTemplateListPane.java | 8 + .../fr/design/file/MutilTempalteTabPane.java | 2 +- .../com/fr/design/fun/ElementUIProvider.java | 2 +- .../gui/chart/BaseChartPropertyPane.java | 6 +- .../gui/chart/ChartEditPaneProvider.java | 13 + .../fr/design/gui/frpane/UIComboBoxPane.java | 3 + .../gui/itree/filetree/EnvFileTree.java | 3 - .../design/mainframe/HelpDialogManager.java | 1 + .../fr/design/module/DesignModuleFactory.java | 2 +- .../com/fr/design/selection/QuickEditor.java | 8 + .../gui/active/DataSeriesActiveGlyph.java | 6 +- .../action/SetAnalysisLineStyleAction.java | 4 +- .../gui/active/action/SetAxisStyleAction.java | 6 +- .../active/action/SetChartStyleAciton.java | 4 +- .../action/SetDataLabelStyleAction.java | 4 +- .../action/SetDataSeriesAttrAction.java | 4 +- .../gui/active/action/SetDataSheetAction.java | 4 +- .../active/action/SetLegendStyleAction.java | 4 +- .../gui/active/action/SetPlotStyleAction.java | 4 +- .../active/action/SetTitleStyleAction.java | 4 +- .../impl/ChartHyperPoplinkPane.java | 6 +- .../mainframe/ChartAndWidgetPropertyPane.java | 143 ------ .../fr/design/mainframe/ChartDesigner.java | 34 -- .../mainframe/ChartDesignerPropertyPane.java | 134 ------ .../design/mainframe/ChartPropertyPane.java | 13 +- .../fr/design/mainframe/ChartUndoState.java | 47 -- .../src/com/fr/design/mainframe/JChart.java | 376 ---------------- .../mainframe/MiddleChartPropertyPane.java | 16 +- .../actions/AbstractExportAction4JChart.java | 132 ------ .../actions/ExcelExportAction4Chart.java | 68 --- .../mainframe/actions/JChartAction.java | 21 - .../mainframe/actions/NewChartAction.java | 61 --- .../actions/PDFExportAction4Chart.java | 65 --- .../actions/PNGExportAction4Chart.java | 66 --- .../chart/AbstractChartAttrPane.java | 1 + .../design/mainframe/chart/ChartEditPane.java | 16 +- .../mainframe/chart/gui/ChartDataPane.java | 1 + .../chart/gui/ChartTypeButtonPane.java | 32 +- .../chart/gui/data/DatabaseTableDataPane.java | 1 + .../chart/gui/data/NormalChartDataPane.java | 1 + .../chart/gui/data/ReportDataPane.java | 6 +- .../chart/gui/other/ChartSwitchPane.java | 4 +- .../exporter/ExcelExporter4Chart.java | 94 ---- .../mainframe/exporter/Exporter4Chart.java | 25 -- .../exporter/ImageExporter4Chart.java | 89 ---- .../mainframe/exporter/PdfExporter4Chart.java | 382 ---------------- .../fr/design/module/ChartDesignerModule.java | 2 +- .../fr/design/module/ChartStartModule.java | 95 ---- .../src/com/fr/start/ChartSplashPane.java | 18 - .../src/com/fr/start/Designer4Chart.java | 406 ------------------ .../fr/design/mainframe/CoverReportPane.java | 22 +- .../mainframe/FormHierarchyTreePane.java | 6 + 61 files changed, 232 insertions(+), 2432 deletions(-) delete mode 100644 designer_base/src/com/fr/design/event/TemplateTreeDragSource.java create mode 100644 designer_base/src/com/fr/design/gui/chart/ChartEditPaneProvider.java delete mode 100644 designer_chart/src/com/fr/design/mainframe/ChartAndWidgetPropertyPane.java delete mode 100644 designer_chart/src/com/fr/design/mainframe/ChartDesignerPropertyPane.java delete mode 100644 designer_chart/src/com/fr/design/mainframe/ChartUndoState.java delete mode 100644 designer_chart/src/com/fr/design/mainframe/JChart.java delete mode 100644 designer_chart/src/com/fr/design/mainframe/actions/AbstractExportAction4JChart.java delete mode 100644 designer_chart/src/com/fr/design/mainframe/actions/ExcelExportAction4Chart.java delete mode 100644 designer_chart/src/com/fr/design/mainframe/actions/JChartAction.java delete mode 100644 designer_chart/src/com/fr/design/mainframe/actions/NewChartAction.java delete mode 100644 designer_chart/src/com/fr/design/mainframe/actions/PDFExportAction4Chart.java delete mode 100644 designer_chart/src/com/fr/design/mainframe/actions/PNGExportAction4Chart.java delete mode 100644 designer_chart/src/com/fr/design/mainframe/exporter/ExcelExporter4Chart.java delete mode 100644 designer_chart/src/com/fr/design/mainframe/exporter/Exporter4Chart.java delete mode 100644 designer_chart/src/com/fr/design/mainframe/exporter/ImageExporter4Chart.java delete mode 100644 designer_chart/src/com/fr/design/mainframe/exporter/PdfExporter4Chart.java delete mode 100644 designer_chart/src/com/fr/design/module/ChartStartModule.java delete mode 100644 designer_chart/src/com/fr/start/ChartSplashPane.java delete mode 100644 designer_chart/src/com/fr/start/Designer4Chart.java diff --git a/designer/src/com/fr/design/module/DesignerModule.java b/designer/src/com/fr/design/module/DesignerModule.java index 13dc722dc8..9e0837ac09 100644 --- a/designer/src/com/fr/design/module/DesignerModule.java +++ b/designer/src/com/fr/design/module/DesignerModule.java @@ -111,17 +111,17 @@ public class DesignerModule extends DesignModule { */ private void registerCellEditor() { - ActionFactory.registerCellEditor(String.class, CellStringQuickEditor.getInstance()); - ActionFactory.registerCellEditor(Number.class, CellStringQuickEditor.getInstance()); - ActionFactory.registerCellEditor(Formula.class, CellStringQuickEditor.getInstance()); - ActionFactory.registerCellEditor(SubReport.class, CellSubReportEditor.getInstance()); - ActionFactory.registerCellEditor(RichText.class, CellRichTextEditor.getInstance()); - ActionFactory.registerCellEditor(DSColumn.class, CellDScolumnEditor.getInstance()); - ActionFactory.registerCellEditor(Image.class, CellImageQuickEditor.getInstance()); - ActionFactory.registerCellEditor(BiasTextPainter.class, new CellBiasTextPainterEditor()); - ActionFactory.registerCellEditor(BufferedImage.class, CellImageQuickEditor.getInstance()); - - ActionFactory.registerChartCellEditorInEditor(ChartQuickEditor.getInstance()); + ActionFactory.registerCellEditor(String.class, CellStringQuickEditor.class); + ActionFactory.registerCellEditor(Number.class, CellStringQuickEditor.class); + ActionFactory.registerCellEditor(Formula.class, CellStringQuickEditor.class); + ActionFactory.registerCellEditor(SubReport.class, CellSubReportEditor.class); + ActionFactory.registerCellEditor(RichText.class, CellRichTextEditor.class); + ActionFactory.registerCellEditor(DSColumn.class, CellDSColumnEditor.class); + ActionFactory.registerCellEditor(Image.class, CellImageQuickEditor.class); + ActionFactory.registerCellEditor(BiasTextPainter.class, CellBiasTextPainterEditor.class); + ActionFactory.registerCellEditor(BufferedImage.class, CellImageQuickEditor.class); + + ActionFactory.registerChartCellEditorInEditor(ChartQuickEditor.class); Set providers = ExtraDesignClassManager.getInstance().getArray(ElementUIProvider.MARK_STRING); for (ElementUIProvider provider : providers) { @@ -139,14 +139,13 @@ public class DesignerModule extends DesignModule { * kunnat: 注册悬浮选中Editor */ private void registerFloatEditor() { - FloatStringQuickEditor floatStringQuickEditor = new FloatStringQuickEditor(); - ActionFactory.registerFloatEditor(String.class, floatStringQuickEditor); - ActionFactory.registerFloatEditor(Formula.class, floatStringQuickEditor); + ActionFactory.registerFloatEditor(String.class, FloatStringQuickEditor.class); + ActionFactory.registerFloatEditor(Formula.class, FloatStringQuickEditor.class); FloatImageQuickEditor floatImageQuickEditor = new FloatImageQuickEditor(); - ActionFactory.registerFloatEditor(Image.class, floatImageQuickEditor); - ActionFactory.registerFloatEditor(BufferedImage.class, floatImageQuickEditor); - ActionFactory.registerChartFloatEditorInEditor(ChartQuickEditor.getInstance()); + ActionFactory.registerFloatEditor(Image.class, FloatImageQuickEditor.class); + ActionFactory.registerFloatEditor(BufferedImage.class, FloatImageQuickEditor.class); + ActionFactory.registerChartFloatEditorInEditor(ChartQuickEditor.class); } /** diff --git a/designer/src/com/fr/poly/creator/ChartBlockCreator.java b/designer/src/com/fr/poly/creator/ChartBlockCreator.java index ca939295be..ca8106ffae 100644 --- a/designer/src/com/fr/poly/creator/ChartBlockCreator.java +++ b/designer/src/com/fr/poly/creator/ChartBlockCreator.java @@ -142,7 +142,7 @@ public class ChartBlockCreator extends BlockCreator { @Override public QuickEditor getQuickEditor(TargetComponent tc) { - ChartQuickEditor quitEditor = ChartQuickEditor.getInstance(); + ChartQuickEditor quitEditor = new ChartQuickEditor(); quitEditor.populate(tc); return quitEditor; } diff --git a/designer/src/com/fr/quickeditor/CellQuickEditor.java b/designer/src/com/fr/quickeditor/CellQuickEditor.java index e1b11cedab..1190b433a6 100644 --- a/designer/src/com/fr/quickeditor/CellQuickEditor.java +++ b/designer/src/com/fr/quickeditor/CellQuickEditor.java @@ -30,7 +30,7 @@ import java.awt.event.MouseEvent; */ public abstract class CellQuickEditor extends QuickEditor { - protected UITextField columnRowTextField; + protected UITextField columnRowTextField; protected UIButton cellElementEditButton; protected TemplateCellElement cellElement; diff --git a/designer/src/com/fr/quickeditor/ChartQuickEditor.java b/designer/src/com/fr/quickeditor/ChartQuickEditor.java index c187f1a449..f0f68a9a73 100644 --- a/designer/src/com/fr/quickeditor/ChartQuickEditor.java +++ b/designer/src/com/fr/quickeditor/ChartQuickEditor.java @@ -16,29 +16,17 @@ import com.fr.design.selection.QuickEditor; import java.awt.*; public class ChartQuickEditor extends QuickEditor{ - private static ChartQuickEditor THIS; - // kunsnat: editingPropertyPane初始化 避开设计器启动, 在用到的时候再初始化. - private BaseChartPropertyPane editingPropertyPane = null; - - public static final ChartQuickEditor getInstance() { - if(THIS == null) { - THIS = new ChartQuickEditor(); - } - return THIS; - } + //private BaseChartPropertyPane editingPropertyPane = null; - private ChartQuickEditor() { + public ChartQuickEditor() { setLayout(new BorderLayout()); setBorder(null); } @Override protected void refresh() { - if(editingPropertyPane != null) { - remove(editingPropertyPane); - } - + BaseChartPropertyPane editingPropertyPane = null; BaseChartCollection collection = null; if(tc instanceof PolyDesigner) { ChartBlockEditor chartBlockEditor = (ChartBlockEditor)((PolyDesigner)tc).getSelection().getEditor(); diff --git a/designer_base/src/com/fr/design/actions/core/ActionFactory.java b/designer_base/src/com/fr/design/actions/core/ActionFactory.java index 4b3eecb3ca..55a72002f4 100644 --- a/designer_base/src/com/fr/design/actions/core/ActionFactory.java +++ b/designer_base/src/com/fr/design/actions/core/ActionFactory.java @@ -10,6 +10,7 @@ import com.fr.design.selection.QuickEditor; import javax.swing.*; import java.awt.event.KeyEvent; import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; import java.util.*; /** @@ -22,11 +23,11 @@ public class ActionFactory { private ActionFactory() { } - private static Map floatEditor = new HashMap(); + private static Map> floatEditor = new HashMap>(); private static Class chartCollectionClass = null; - private static Map cellEditor = new HashMap(); + private static Map> cellEditor = new HashMap>(); private static UpdateAction chartPreStyleAction = null; @@ -36,17 +37,18 @@ public class ActionFactory { * @param clazz 待说明 * @param editor 待说明 */ - public static void registerCellEditor(Class clazz, QuickEditor editor) { + public static void registerCellEditor(Class clazz, Class editor) { cellEditor.put(clazz, editor); } + /** * 待说明 * * @param clazz 待说明 * @param editor 待说明 */ - public static void registerFloatEditor(Class clazz, QuickEditor editor) { + public static void registerFloatEditor(Class clazz, Class editor) { floatEditor.put(clazz, editor); } @@ -84,7 +86,7 @@ public class ActionFactory { * * @param editor 待说明 */ - public static void registerChartFloatEditorInEditor(QuickEditor editor) { + public static void registerChartFloatEditorInEditor(Class editor) { if (chartCollectionClass != null) { floatEditor.put(chartCollectionClass, editor); } @@ -95,7 +97,7 @@ public class ActionFactory { * * @param editor 待说明 */ - public static void registerChartCellEditorInEditor(QuickEditor editor) { + public static void registerChartCellEditorInEditor(Class editor) { if (chartCollectionClass != null) { cellEditor.put(chartCollectionClass, editor); } @@ -105,11 +107,29 @@ public class ActionFactory { * 返回 悬浮元素选中的Editor */ public static QuickEditor getFloatEditor(Class clazz) { - return floatEditor.get(clazz); + return createEditor(clazz, floatEditor); + } + + private static QuickEditor createEditor(Class clazz, Map> editorMap) { + Class c = editorMap.get(clazz); + try { + Constructor constructor = c.getDeclaredConstructor(); + constructor.setAccessible(true); + return constructor.newInstance(); + } catch (NoSuchMethodException e) { + FRContext.getLogger().error(e.getMessage(), e); + } catch (IllegalAccessException e) { + FRContext.getLogger().error(e.getMessage(), e); + } catch (InstantiationException e) { + FRContext.getLogger().error(e.getMessage(), e); + } catch (InvocationTargetException e) { + FRContext.getLogger().error(e.getMessage(), e); + } + return null; } public static QuickEditor getCellEditor(Class clazz) { - return cellEditor.get(clazz); + return createEditor(clazz, cellEditor); } /** diff --git a/designer_base/src/com/fr/design/actions/file/SwitchExistEnv.java b/designer_base/src/com/fr/design/actions/file/SwitchExistEnv.java index 8854e777b8..8545d85d06 100644 --- a/designer_base/src/com/fr/design/actions/file/SwitchExistEnv.java +++ b/designer_base/src/com/fr/design/actions/file/SwitchExistEnv.java @@ -10,6 +10,7 @@ import com.fr.design.DesignerEnvManager; import com.fr.design.actions.UpdateAction; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.TemplatePane; import com.fr.design.menu.KeySetUtils; import com.fr.design.menu.MenuDef; @@ -41,12 +42,15 @@ public class SwitchExistEnv extends MenuDef { this.setName(getMenuKeySet().getMenuName()); this.setHasScrollSubMenu(true); initMenuDef(); - GeneralContext.addEnvWillChangedListener(new EnvChangedListener() { - public void envChanged() { - SwitchExistEnv.this.clearShortCuts(); - initMenuDef(); - } - }); + JTemplate t = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); + if(t != null) { + GeneralContext.addEnvWillChangedListener(t.getFullPathName(), new EnvChangedListener() { + public void envChanged() { + SwitchExistEnv.this.clearShortCuts(); + initMenuDef(); + } + }); + } } private void initMenuDef() { diff --git a/designer_base/src/com/fr/design/data/DesignTableDataManager.java b/designer_base/src/com/fr/design/data/DesignTableDataManager.java index 5ec6dd1d57..e0569424dc 100644 --- a/designer_base/src/com/fr/design/data/DesignTableDataManager.java +++ b/designer_base/src/com/fr/design/data/DesignTableDataManager.java @@ -13,8 +13,10 @@ import com.fr.data.impl.storeproc.StoreProcedure; import com.fr.data.impl.storeproc.StoreProcedureConstants; import com.fr.design.data.tabledata.wrapper.*; import com.fr.design.DesignModelAdapter; +import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.gui.iprogressbar.AutoProgressBar; import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.JTemplate; import com.fr.design.parameter.ParameterInputPane; import com.fr.design.dialog.DialogActionAdapter; import com.fr.file.DatasourceManager; @@ -34,6 +36,7 @@ import java.io.ByteArrayOutputStream; import java.text.Collator; import java.util.*; import java.util.Map.Entry; +import java.util.concurrent.ConcurrentHashMap; /** * 设计器管理操作数据集的类: @@ -54,7 +57,10 @@ public abstract class DesignTableDataManager { */ private static java.util.Map globalDsCache = new java.util.HashMap(); private static java.util.Map dsNameChangedMap = new HashMap(); - private static List dsListeners = new ArrayList(); +// private static List dsListeners = new ArrayList(); + + private static Map> dsListenersMap = new HashMap>(); + public static String NO_PARAMETER = "no_paramater_pane"; @@ -73,15 +79,31 @@ public abstract class DesignTableDataManager { * 响应数据集改变. */ private static void fireDsChanged() { - for (int i = 0; i < dsListeners.size(); i++) { - //增强for循环用的iterator实现的, 如果中间哪个listener修改或删除了(如ChartEditPane.dsChangeListener), - // 由于dsListeners是arraylist, 此时会ConcurrentModifyException + for(Entry> listenerEntry : dsListenersMap.entrySet()) { + List dsListeners = listenerEntry.getValue(); + for (int i = 0; i < dsListeners.size(); i++) { + //增强for循环用的iterator实现的, 如果中间哪个listener修改或删除了(如ChartEditPane.dsChangeListener), + // 由于dsListeners是arraylist, 此时会ConcurrentModifyException // for (ChangeListener l : dsListeners) { - ChangeEvent e = null; - dsListeners.get(i).stateChanged(e); + ChangeEvent e = null; + dsListeners.get(i).stateChanged(e); + } + } + } + + public static void closeTemplate(JTemplate template) { + if(template != null) { + dsListenersMap.remove(template.getFullPathName()); } } + public static void envChange() { + dsListenersMap.clear(); + dsNameChangedMap.clear(); + clearGlobalDs(); + } + + /** * 响应数据集改变 * @@ -127,6 +149,16 @@ public abstract class DesignTableDataManager { * @param l ChangeListener监听器 */ public static void addDsChangeListener(ChangeListener l) { + JTemplate template = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); + String key = StringUtils.EMPTY; + if(template != null) { + key = template.getFullPathName(); + } + List dsListeners = dsListenersMap.get(key); + if (dsListeners == null) { + dsListeners = new ArrayList(); + dsListenersMap.put(key, dsListeners); + } dsListeners.add(l); } diff --git a/designer_base/src/com/fr/design/data/datapane/TableDataComboBox.java b/designer_base/src/com/fr/design/data/datapane/TableDataComboBox.java index 711c2fc717..4286bbe4ba 100644 --- a/designer_base/src/com/fr/design/data/datapane/TableDataComboBox.java +++ b/designer_base/src/com/fr/design/data/datapane/TableDataComboBox.java @@ -146,4 +146,5 @@ public class TableDataComboBox extends UIComboBox implements Prepare4DataSourceC } }); } + } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/event/TemplateTreeDragSource.java b/designer_base/src/com/fr/design/event/TemplateTreeDragSource.java deleted file mode 100644 index 7b387305c1..0000000000 --- a/designer_base/src/com/fr/design/event/TemplateTreeDragSource.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.fr.design.event; - -import com.fr.design.gui.itree.filetree.TemplateFileTree; -import com.fr.design.mainframe.dnd.ArrayTransferable; -import com.fr.design.mainframe.dnd.SerializableTransferable; -import com.fr.general.web.ParameterConsts; -import com.fr.stable.StringUtils; - -import javax.swing.*; -import java.awt.*; -import java.awt.dnd.DragGestureEvent; -import java.awt.dnd.DragGestureListener; -import java.awt.dnd.DragSource; -import java.awt.dnd.DragSourceAdapter; - -/** - * Created with IntelliJ IDEA. - * User: richie - * Date: 13-11-4 - * Time: 下午2:17 - */ -public class TemplateTreeDragSource extends DragSourceAdapter implements DragGestureListener { - private DragSource source; - - public TemplateTreeDragSource(JTree tree, int actions) { - source = new DragSource(); - source.createDefaultDragGestureRecognizer(tree, actions, this); - - } - public void dragGestureRecognized(DragGestureEvent dge) { - Component comp = dge.getComponent(); - if (comp instanceof TemplateFileTree) { - String selectedPath = ((TemplateFileTree)comp).getSelectedTemplatePath(); - source.startDrag(dge, DragSource.DefaultLinkDrop, new SerializableTransferable(selectedPath), this); - } - } -} \ No newline at end of file diff --git a/designer_base/src/com/fr/design/file/HistoryTemplateListPane.java b/designer_base/src/com/fr/design/file/HistoryTemplateListPane.java index 26aa72f146..50cdf00cf9 100644 --- a/designer_base/src/com/fr/design/file/HistoryTemplateListPane.java +++ b/designer_base/src/com/fr/design/file/HistoryTemplateListPane.java @@ -9,8 +9,11 @@ import java.util.logging.Level; import javax.swing.*; +import com.fr.chart.chartattr.ChartCollection; +import com.fr.design.actions.core.ActionFactory; import com.fr.design.constants.UIConstants; import com.fr.design.DesignerEnvManager; +import com.fr.design.data.DesignTableDataManager; import com.fr.design.gui.ilable.UILabel; import javax.swing.event.ListSelectionEvent; @@ -24,9 +27,11 @@ import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilist.UIList; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.JTemplate; +import com.fr.design.module.DesignModuleFactory; import com.fr.file.filetree.FileNode; import com.fr.general.ComparatorUtils; import com.fr.general.FRLogger; +import com.fr.general.GeneralContext; import com.fr.general.Inter; import com.fr.stable.Constants; import com.fr.stable.project.ProjectConstants; @@ -102,6 +107,9 @@ public class HistoryTemplateListPane extends JPanel implements FileOperations { * @param selected 选择的 */ public void closeSelectedReport(JTemplate selected) { + DesignModuleFactory.clearChartPropertyPane(); + DesignTableDataManager.closeTemplate(selected); + GeneralContext.removeEnvWillChangedListener(selected.getFullPathName()); if (contains(selected) == -1) { return; } diff --git a/designer_base/src/com/fr/design/file/MutilTempalteTabPane.java b/designer_base/src/com/fr/design/file/MutilTempalteTabPane.java index 15c0f0bfbf..794c6a5e44 100644 --- a/designer_base/src/com/fr/design/file/MutilTempalteTabPane.java +++ b/designer_base/src/com/fr/design/file/MutilTempalteTabPane.java @@ -1 +1 @@ -package com.fr.design.file; import java.awt.AWTEvent; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.awt.Font; import java.awt.GradientPaint; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.RenderingHints; import java.awt.Toolkit; import java.awt.event.AWTEventListener; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; import java.awt.geom.Arc2D; import java.awt.geom.GeneralPath; import java.awt.geom.Line2D; import java.awt.geom.Path2D; import java.awt.geom.RoundRectangle2D; import java.io.File; import java.util.logging.Level; import javax.swing.Action; import javax.swing.BorderFactory; import javax.swing.ButtonModel; import javax.swing.Icon; import javax.swing.JComponent; import javax.swing.JMenu; import javax.swing.JMenuItem; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JSeparator; import javax.swing.plaf.basic.BasicMenuItemUI; import com.fr.base.BaseUtils; import com.fr.base.GraphHelper; import com.fr.design.constants.UIConstants; import com.fr.design.gui.imenu.UIMenuItem; import com.fr.design.gui.imenu.UIScrollPopUpMenu; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.JTemplate; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUIPaintUtils; import com.fr.file.FILE; import com.fr.file.FileNodeFILE; import com.fr.general.ComparatorUtils; import com.fr.general.FRLogger; import com.fr.general.Inter; import com.fr.stable.Constants; import com.fr.stable.ProductConstants; import com.fr.stable.project.ProjectConstants; /** * Author : daisy * Date: 13-8-5 * Time: 下午6:12 */ public class MutilTempalteTabPane extends JComponent implements MouseListener, MouseMotionListener, Action { private static Icon LIST_DOWN = BaseUtils.readIcon("/com/fr/design/images/buttonicon/list_normal.png"); private static Icon MOUSE_OVER_LIST_DOWN = BaseUtils.readIcon("/com/fr/design/images/buttonicon/list_pressed.png"); private static Icon MOUSE_PRESS_LIST_DOWN = BaseUtils.readIcon("/com/fr/design/images/buttonicon/list_pressed.png"); private static Icon CLOSE = BaseUtils.readIcon("/com/fr/design/images/buttonicon/close_icon.png"); private static Icon MOUSE_OVER_CLOSE = BaseUtils.readIcon("/com/fr/design/images/buttonicon/mouseoverclose icon.png"); private static Icon MOUSE_PRESS_CLOSE = BaseUtils.readIcon("/com/fr/design/images/buttonicon/pressclose icon.png"); private static final String ELLIPSIS = "..."; private static final int GAP_BEFORE_CLOSE = 10; private static final int GAP = 5; private static final int SMALLGAP = 3; private static final int LIST_BUTTON_WIDTH = 34; private static final int HEIGHT = 26; private static final int LIST_DOWN_HEIGHT = 25; private static final double FOR_CAL_BYTES = 0.5; private static final double CORNOR_RADIUS = 0.0; //选了30度和60度的特殊角度的x,y作为经过的两个点的坐标 private static final double SPECIAL_LOCATION_1 = 2.5; private static final double SPECIAL_LOCATION_2 = 4.330127; private static final int ICON_WIDTH = 22; //每个标签页的最大的长度和最小长度。这些长度均为均分 private static final int MAXWIDTH = 240; private static final int MINWIDTH = 100; private static MutilTempalteTabPane THIS; //用于存放工作簿 private java.util.List> openedTemplate; //选中的Tab项 private int selectedIndex = 0; // private int mouseOveredIndex = -1; //tab栏可以放下的每个tab的实际宽度 private int realWidth = MAXWIDTH; //当前标签页栏存放的所有标签页的index private int minPaintIndex = 0; private int maxPaintIndex = 0; /** * 鼠标按下时的坐标数组、鼠标放开时的坐标数组 */ private int[] xyPressedCoordinate = {0, 0}; //每个关闭图标的起始位置 private int[] startX; private boolean[] isNeedToolTips; private Graphics2D g2d; //记录关闭按钮的状态 private int closeIconIndex = -1; private boolean isCloseCurrent = false; private Icon clodeMode = CLOSE; private Icon listDownMode = LIST_DOWN; private boolean isShowList = false; //自动新建的模板B若没有进行任何编辑,切换到其他 // // 模板时,模板B会自动关闭 private JTemplate temTemplate = null; private AWTEventListener awt = new AWTEventListener() { public void eventDispatched(AWTEvent event) { if (event instanceof MouseEvent) { MouseEvent mv = (MouseEvent) event; if (mv.getClickCount() > 0 && !ComparatorUtils.equals(mv.getSource(), MutilTempalteTabPane.this)) { isShowList = false; } } } }; public static final MutilTempalteTabPane getInstance() { if (THIS == null) { THIS = new MutilTempalteTabPane(); } return THIS; } public JTemplate getSelectedFile() { return openedTemplate.get(selectedIndex); } /** * 关闭掉当前已打开文件列表中指定的文件 * * @param file 指定的文件 * */ public void closeFileTemplate(FILE file){ for (JTemplate temp : openedTemplate) { if(ComparatorUtils.equals(file, temp.getEditingFILE())){ closeSpecifiedTemplate(temp); break; } } } public Dimension getPreferredSize() { Dimension dimension = super.getPreferredSize(); dimension.height = HEIGHT; return dimension; } /** * 多工作簿面板 */ public MutilTempalteTabPane() { this.setLayout(new BorderLayout(0, 0)); this.addMouseListener(this); this.addMouseMotionListener(this); this.setBorder(null); this.setForeground(new Color(99, 99, 99)); this.setFont(new Font(Inter.getLocText("FR-Designer_Song_TypeFace"), 0, 12)); openedTemplate = HistoryTemplateListPane.getInstance().getHistoryList(); selectedIndex = openedTemplate.size() - 1; Toolkit.getDefaultToolkit().addAWTEventListener(awt, AWTEvent.MOUSE_EVENT_MASK); } private UIMenuItem initCloseOther() { UIMenuItem closeOther = new UIMenuItem(Inter.getLocText("FR-Designer_FS_Close_Other_Templates")); setListDownItemPreferredSize(closeOther); closeOther.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (openedTemplate.size() == 1) { return; } SaveSomeTemplatePane saveSomeTempaltePane = new SaveSomeTemplatePane(false); //点击关闭其他模板,并且点击确定保存 if (saveSomeTempaltePane.showSavePane()) { for (int i = 0; i < openedTemplate.size(); i++) { if (i != selectedIndex) { //判断关闭的模板是不是格式刷的被参照的模板 closeFormat(openedTemplate.get(i)); HistoryTemplateListPane.getInstance().closeSelectedReport(openedTemplate.get(i)); } } JTemplate currentTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); HistoryTemplateListPane.getInstance().removeAllHistory(); DesignerContext.getDesignerFrame().activateJTemplate(currentTemplate); THIS.repaint(); } //如果取消保存了,则不关闭其他模板 } }); if (openedTemplate.size() == 1) { closeOther.setEnabled(false); } return closeOther; } private UIMenuItem[] createListDownTemplate() { UIMenuItem[] templates = new UIMenuItem[openedTemplate.size()]; for (int i = 0; i < openedTemplate.size(); i++) { final int index = i; final JTemplate tem = openedTemplate.get(i); templates[i] = new UIMenuItem(tempalteShowName(tem), tem.getIcon()); templates[i].setUI(new UIListDownItemUI()); setListDownItemPreferredSize(templates[i]); if (i == selectedIndex) { //画选中的高亮 templates[i].setBackground(UIConstants.SHADOW_CENTER); } templates[i].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { selectedIndex = index; DesignerContext.getDesignerFrame().addAndActivateJTemplate(tem); } }); } return templates; } private void setListDownItemPreferredSize(UIMenuItem item) { Dimension dimension = item.getPreferredSize(); dimension.height = LIST_DOWN_HEIGHT; item.setPreferredSize(dimension); } private String tempalteShowName(JTemplate template) { String name = template.getEditingFILE().getName(); if (!template.isSaved() && !name.endsWith(" *")) { name += " *"; } return name; } /** * 刷新打开模板 * @param history 模板 */ public void refreshOpenedTemplate(java.util.List> history) { openedTemplate = history; } public void setTemTemplate(JTemplate auotCreate) { temTemplate = auotCreate; } private void showListDown() { UIScrollPopUpMenu menu = new UIScrollPopUpMenu(); menu.setBorder(BorderFactory.createEmptyBorder(-3, 3, 3, 0)); menu.add(initCloseOther()); JSeparator separator = new JSeparator() { public Dimension getPreferredSize() { Dimension d = super.getPreferredSize(); d.height = 1; return d; } }; menu.add(new JPanel() { public Dimension getPreferredSize() { Dimension d = super.getPreferredSize(); d.height = 1; return d; } }); separator.setForeground(UIConstants.LINE_COLOR); menu.add(separator); menu.add(new JPanel() { public Dimension getPreferredSize() { Dimension d = super.getPreferredSize(); d.height = 1; return d; } }); UIMenuItem[] items = createListDownTemplate(); for (int i = 0; i < items.length; i++) { menu.add(items[i]); } GUICoreUtils.showPopupMenu(menu, MutilTempalteTabPane.getInstance(), MutilTempalteTabPane.getInstance().getWidth() - menu.getPreferredSize().width, getY() - 1 + getHeight()); } public void setSelectedIndex(int index) { selectedIndex = index; } public void paintComponent(Graphics g) { super.paintComponent(g); double maxWidth = getWidth() - LIST_BUTTON_WIDTH; //最大宽度 g2d = (Graphics2D) g; paintBackgroundAndLine(g2d, maxWidth); } private void paintBackgroundAndLine(Graphics2D g2d, double maxWidth) { paintDefaultBackground(g2d); //最多能画的个数 int maxTemplateNum = (int) (maxWidth) / MINWIDTH; //计算开始画的最小模板index和最大模板index calMinAndMaxIndex(maxTemplateNum); calculateRealAverageWidth(maxWidth, maxTemplateNum); int maxStringlength = calculateStringMaxLength(); if (selectedIndex >= openedTemplate.size()) { selectedIndex = openedTemplate.size() - 1; } if (selectedIndex < 0) { selectedIndex = 0; } double templateStartX = 0; startX = new int[maxPaintIndex - minPaintIndex + 1]; isNeedToolTips = new boolean[maxPaintIndex - minPaintIndex + 1]; //从可以开始展示在tab面板上的tab开始画 for (int i = minPaintIndex; i <= maxPaintIndex; i++) { JTemplate template = openedTemplate.get(i); Icon icon = template.getIcon(); String name = tempalteShowName(template); //如果tab名字的长度大于最大能显示的英文字符长度,则进行省略号处理 if (getStringWidth(name) > maxStringlength) { name = getEllipsisName(name, maxStringlength); isNeedToolTips[i - minPaintIndex] = true; } else { isNeedToolTips[i - minPaintIndex] = false; } Icon selectedIcon = null; if (i == closeIconIndex) { selectedIcon = clodeMode; } else { selectedIcon = CLOSE; } if (i == selectedIndex) { startX[i - minPaintIndex] = paintSelectedTab(g2d, icon, templateStartX, name, selectedIcon); } else { boolean isLeft = i < selectedIndex; startX[i - minPaintIndex] = paintUnSelectedTab(g2d, icon, templateStartX, name, selectedIcon, isLeft, mouseOveredIndex, i); } templateStartX += realWidth; } paintListDown(g2d, maxWidth); paintUnderLine(templateStartX, maxWidth, g2d); } private void paintUnderLine(double templateStartX, double maxWidth, Graphics2D g2d) { //画下面的那条线 if (templateStartX < maxWidth) { GeneralPath generalPath = new GeneralPath(Path2D.WIND_EVEN_ODD, 2); generalPath.moveTo((float) templateStartX, getHeight() - 1); generalPath.lineTo((float) maxWidth, getHeight() - 1); g2d.fill(generalPath); g2d.setPaint(UIConstants.LINE_COLOR); g2d.draw(new Line2D.Double((float) templateStartX, getHeight() - 1, (float) maxWidth + LIST_BUTTON_WIDTH, getHeight() - 1)); } } private void paintDefaultBackground(Graphics2D g2d) { //画默认背景 g2d.setPaint(new GradientPaint(1, 1, UIConstants.SHADOW_GREY, 1, getHeight() - 1, UIConstants.SHADOW_GREY)); g2d.fillRect(getX(), getY(), getWidth(), getHeight()); } private void paintListDown(Graphics2D g2d, double maxWidth) { int x = (int) maxWidth + (LIST_BUTTON_WIDTH - listDownMode.getIconWidth()) / 2; int y = (getHeight() - listDownMode.getIconHeight()) / 2; listDownMode.paintIcon(this, g2d, x, y); } /** * 判断tab文字的长度大于能装下的最大文字长度,要用省略号 * * @param name * @param maxStringlength * @return */ private String getEllipsisName(String name, int maxStringlength) { //若是名字长度大于能显示的长度,那能显示的文字的最大长度还要减去省略号的最大长度 // int maxellipsislength = maxStringlength - ELLIPSIS.length(); int ellipsisWidth = getStringWidth(ELLIPSIS); int leftkeyPoint = 0; int rightKeyPoint = name.length() - 1; int leftStrWidth = 0; int rightStrWidth = 0; while (leftStrWidth + rightStrWidth + ellipsisWidth < maxStringlength) { if (leftStrWidth <= rightStrWidth) { leftkeyPoint++; } else { rightKeyPoint--; } leftStrWidth = getStringWidth(name.substring(0, leftkeyPoint)); rightStrWidth = getStringWidth(name.substring(rightKeyPoint)); if (leftStrWidth + rightStrWidth + ellipsisWidth > maxStringlength) { if (leftStrWidth <= rightStrWidth) { rightKeyPoint++; } break; } } return name.substring(0, leftkeyPoint) + ELLIPSIS + name.substring(rightKeyPoint); } private void calMinAndMaxIndex(int maxTemplateNum) { //如果个数大于最多能容纳的个数,则多余的进行处理 if (openedTemplate.size() > maxTemplateNum) { //所点击列表中的标签页处在标签页栏最后一个标签页之后,则标签页栏左移至所点击标签页出现 if (selectedIndex >= maxPaintIndex) { minPaintIndex = selectedIndex - maxTemplateNum + 1; maxPaintIndex = selectedIndex; if (minPaintIndex <= 0) { minPaintIndex = 0; maxPaintIndex = maxTemplateNum - 1; } } else if (selectedIndex <= minPaintIndex) { //所点击列表中的标签页处在标签页栏第一个标签页之前,则标签页栏右移至所点击标签页出现 minPaintIndex = selectedIndex; maxPaintIndex = minPaintIndex + maxTemplateNum - 1; if (maxPaintIndex > openedTemplate.size() - 1) { maxPaintIndex = openedTemplate.size() - 1; } } else { if (selectedIndex >= openedTemplate.size() - 1) { selectedIndex = openedTemplate.size() - 1; maxPaintIndex = selectedIndex; minPaintIndex = selectedIndex - maxTemplateNum + 1; } else { maxPaintIndex = minPaintIndex + maxTemplateNum - 1; if (maxPaintIndex > openedTemplate.size() - 1) { maxPaintIndex = openedTemplate.size() - 1; } } } } else { minPaintIndex = 0; maxPaintIndex = openedTemplate.size() - 1; } } //个数小于最多能容纳的个数的情况下,看看宽度每个要画多少 private void calculateRealAverageWidth(double maxwidth, int templateNum) { int num = openedTemplate.size() > templateNum ? templateNum : openedTemplate.size(); realWidth = (int) (maxwidth / (num)); if (realWidth > MAXWIDTH) { realWidth = MAXWIDTH; } else if (realWidth < MINWIDTH) { //平均下来每个的宽度小于最小宽度 realWidth = MINWIDTH; } } /** * 计算过长度之后的每个tab的能接受的文字的英文字符数 * * @return */ private int calculateStringMaxLength() { return realWidth - 3 * GAP - ICON_WIDTH - SMALLGAP - CLOSE.getIconWidth(); } private int getStringWidth(String str) { return GraphHelper.getFontMetrics(this.getFont()).stringWidth(str); } /** * 画选中的tab * * @param g2d * @param sheeticon * @param templateStartX * @param sheetName * @param closeIcon * @return */ private int paintSelectedTab(Graphics2D g2d, Icon sheeticon, double templateStartX, String sheetName, Icon closeIcon) { double[] x = {templateStartX, templateStartX, templateStartX + realWidth, templateStartX + realWidth, templateStartX}; double[] y = {-1, getHeight(), getHeight(), -1, -1}; RoundRectangle2D.Double rect1 = new RoundRectangle2D.Double(templateStartX, 1, this.getWidth(), this.getHeight(), 7, 7); g2d.setPaint(new GradientPaint(1, 1, UIConstants.NORMAL_BACKGROUND, 1, getHeight() - 1, UIConstants.NORMAL_BACKGROUND)); //选了30度和60度的特殊角度的x,y作为经过的两个点的坐标 double specialLocation1 = 2.5; double specialLocation2 = 4.330127; GeneralPath generalPath = new GeneralPath(Path2D.WIND_EVEN_ODD, x.length); generalPath.moveTo((float) x[0] + CORNOR_RADIUS, (float) y[0]); generalPath.curveTo(((float) x[0] + CORNOR_RADIUS - specialLocation1), (y[0] + CORNOR_RADIUS - specialLocation2), ((float) x[0] + CORNOR_RADIUS - specialLocation2), (y[0] + CORNOR_RADIUS - specialLocation1), x[0], y[0] + CORNOR_RADIUS); for (int index = 1; index <= 2; index++) { generalPath.lineTo((float) x[index], (float) y[index]); } generalPath.lineTo((float) x[3], (float) y[3] + CORNOR_RADIUS); generalPath.curveTo(((float) x[3] - CORNOR_RADIUS + specialLocation1), ((float) y[3] + CORNOR_RADIUS - specialLocation2), ((float) x[3] - CORNOR_RADIUS + specialLocation2), ((float) y[3] + CORNOR_RADIUS - specialLocation1), (float) x[3] - CORNOR_RADIUS, (float) y[3]); generalPath.lineTo((float) x[0] + CORNOR_RADIUS, (float) y[0]); generalPath.closePath(); g2d.fill(generalPath); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setPaint(UIConstants.LINE_COLOR); g2d.draw(new Arc2D.Double(x[0], y[0], CORNOR_RADIUS * 2, CORNOR_RADIUS * 2, 90, 90, 0)); g2d.draw(new Line2D.Double(x[0], y[0] + CORNOR_RADIUS, x[1], y[1])); g2d.draw(new Line2D.Double(x[1], y[1], x[2], y[2])); g2d.draw(new Line2D.Double(x[2], y[2], x[3], y[3] + CORNOR_RADIUS)); g2d.draw(new Arc2D.Double(x[3] - CORNOR_RADIUS * 2, y[3], CORNOR_RADIUS * 2, CORNOR_RADIUS * 2, 90, -90, 0)); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); int sheetIconY = (getHeight() - sheeticon.getIconHeight()) / 2; sheeticon.paintIcon(this, g2d, (int) templateStartX + GAP, sheetIconY); // 画字符 g2d.setPaint(getForeground()); g2d.drawString(sheetName, (int) templateStartX + sheeticon.getIconWidth() + 2 * GAP, getHeight() - GAP * 2); int closePosition = (int) templateStartX + realWidth - CLOSE.getIconWidth() - SMALLGAP; int closeY = (getHeight() - closeIcon.getIconHeight()) / 2; closeIcon.paintIcon(this, g2d, closePosition, closeY); return closePosition; } /** * 画没有选中的tab * * @param g2d * @param sheeticon * @param templateStartX * @param sheetName * @param closeIcon * @param isLeft * @return */ private int paintUnSelectedTab(Graphics2D g2d, Icon sheeticon, double templateStartX, String sheetName, Icon closeIcon, boolean isLeft, int mouseOveredIndex, int selfIndex) { double[] x = {templateStartX, templateStartX, templateStartX + realWidth, templateStartX + realWidth, templateStartX}; double[] y = {-1, getHeight() - 1, getHeight() - 1, -1, -1}; if (selfIndex == mouseOveredIndex) { g2d.setPaint(new GradientPaint(1, 1, UIConstants.HOVER_BLUE, 1, getHeight() - 1, UIConstants.HOVER_BLUE)); } else { g2d.setPaint(new GradientPaint(1, 1, UIConstants.SHADOW_GREY, 1, getHeight() - 1, UIConstants.SHADOW_GREY)); } GeneralPath generalPath = new GeneralPath(Path2D.WIND_EVEN_ODD, x.length); unSelectedClosedPath(generalPath, isLeft, x, y); g2d.fill(generalPath); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setPaint(UIConstants.LINE_COLOR); if (isLeft) { g2d.draw(new Arc2D.Double(x[0], y[0], CORNOR_RADIUS * 2, CORNOR_RADIUS * 2, 90, 90, 0)); } else { g2d.draw(new Arc2D.Double(x[0] - CORNOR_RADIUS * 2, y[0], CORNOR_RADIUS * 2, CORNOR_RADIUS * 2, 90, -90, 0)); } g2d.draw(new Line2D.Double(x[0], y[0] + CORNOR_RADIUS, x[1], y[1] + 1)); g2d.draw(new Line2D.Double(x[1], y[1], x[2], y[2])); g2d.draw(new Line2D.Double(x[2], y[2], x[3], y[3] + CORNOR_RADIUS)); if (isLeft) { g2d.draw(new Arc2D.Double(x[3], y[3], CORNOR_RADIUS * 2, CORNOR_RADIUS * 2, 90, 90, 0)); } else { g2d.draw(new Arc2D.Double(x[3] - CORNOR_RADIUS * 2, y[3], CORNOR_RADIUS * 2, CORNOR_RADIUS * 2, 90, -90, 0)); } g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); int sheetIconY = (getHeight() - sheeticon.getIconHeight()) / 2; sheeticon.paintIcon(this, g2d, (int) templateStartX + GAP, sheetIconY); // 画字符 g2d.setPaint(getForeground()); g2d.drawString(sheetName, (int) templateStartX + sheeticon.getIconWidth() + 2 * GAP, getHeight() - GAP * 2); int closeY = (getHeight() - closeIcon.getIconHeight()) / 2; int closePosition = (int) templateStartX + realWidth - CLOSE.getIconWidth() - SMALLGAP; closeIcon.paintIcon(this, g2d, closePosition, closeY); return closePosition; } private void unSelectedClosedPath(GeneralPath generalPath, boolean isLeft, double[] x, double[] y) { if (isLeft) { generalPath.moveTo((float) x[0] + CORNOR_RADIUS, (float) y[0]); generalPath.curveTo(((float) x[0] + CORNOR_RADIUS - SPECIAL_LOCATION_1), (y[0] + CORNOR_RADIUS - SPECIAL_LOCATION_2), ((float) x[0] + CORNOR_RADIUS - SPECIAL_LOCATION_2), (y[0] + CORNOR_RADIUS - SPECIAL_LOCATION_1), x[0], y[0] + CORNOR_RADIUS); } else { generalPath.moveTo((float) x[0] - CORNOR_RADIUS, (float) y[0]); generalPath.curveTo(((float) x[0] - CORNOR_RADIUS + SPECIAL_LOCATION_1), (y[0] + CORNOR_RADIUS - SPECIAL_LOCATION_2), ((float) x[0] - CORNOR_RADIUS + SPECIAL_LOCATION_2), (y[0] + CORNOR_RADIUS - SPECIAL_LOCATION_1), x[0], y[0] + CORNOR_RADIUS); } for (int index = 1; index <= 2; index++) { generalPath.lineTo((float) x[index], (float) y[index]); } generalPath.lineTo((float) x[3], (float) y[3] + CORNOR_RADIUS); if (isLeft) { generalPath.curveTo(((float) x[3] + CORNOR_RADIUS - SPECIAL_LOCATION_1), ((float) y[3] + CORNOR_RADIUS - SPECIAL_LOCATION_2), ((float) x[3] + CORNOR_RADIUS - SPECIAL_LOCATION_2), ((float) y[3] - CORNOR_RADIUS + SPECIAL_LOCATION_1), (float) x[3] + CORNOR_RADIUS, (float) y[3]); generalPath.lineTo((float) x[0] + CORNOR_RADIUS, (float) y[0]); } else { generalPath.curveTo(((float) x[3] - CORNOR_RADIUS + SPECIAL_LOCATION_1), ((float) y[3] + CORNOR_RADIUS - SPECIAL_LOCATION_2), ((float) x[3] - CORNOR_RADIUS + SPECIAL_LOCATION_2), ((float) y[3] + CORNOR_RADIUS - SPECIAL_LOCATION_1), (float) x[3] - CORNOR_RADIUS, (float) y[3]); generalPath.lineTo((float) x[0] - CORNOR_RADIUS, (float) y[0]); } generalPath.closePath(); } /** * 点击 * @param e 鼠标事件 */ public void mouseClicked(MouseEvent e) { } /** * 按下 * @param e 鼠标事件 */ public void mousePressed(MouseEvent e) { int evtX = e.getX(); int evtY = e.getY(); this.setPressedXY(evtX, evtY); //是否点击关闭按钮 如果点击了关闭按钮,则将点击的模板关闭,不需要切换,如果没有点击关闭按钮,则切换到点击的模板处 boolean isOverCloseIcon = isOverCloseIcon(evtX); if (isOverListDown(evtX)) { listDownMode = isOverListDown(evtX) ? MOUSE_PRESS_LIST_DOWN : LIST_DOWN; if (!isShowList) { showListDown(); } isShowList = !isShowList; } else if (isOverCloseIcon) { //关闭按钮的图标变化 closeIconIndex = getTemplateIndex(evtX); clodeMode = MOUSE_PRESS_CLOSE; //关闭close图标所在的模板{ closeFormat(openedTemplate.get(closeIconIndex)); closeSpecifiedTemplate(openedTemplate.get(closeIconIndex)); DesignerContext.getDesignerFrame().getContentFrame().repaint(); isShowList = false; } else { //没有点击关闭和ListDown按钮,则切换到点击的模板处 closeIconIndex = -1; clodeMode = CLOSE; int tempSelectedIndex = selectedIndex; if (selectedIndex != getTemplateIndex(evtX) && getTemplateIndex(evtX) != -1) { openedTemplate.get(selectedIndex).stopEditing(); selectedIndex = getTemplateIndex(evtX); //如果在权限编辑情况下,不允许切换到表单类型的工作簿 if(BaseUtils.isAuthorityEditing() && !openedTemplate.get(selectedIndex).isJWorkBook()){ DesignerContext.getDesignerFrame().addAndActivateJTemplate(openedTemplate.get(tempSelectedIndex)); JOptionPane.showMessageDialog(this, Inter.getLocText("FR-Designer_Form-AuthorityEdited_Cannot_be_Supported") + "!", Inter.getLocText("FR-Designer_Alert"), JOptionPane.WARNING_MESSAGE); this.repaint(); return; } DesignerContext.getDesignerFrame().addAndActivateJTemplate(openedTemplate.get(getTemplateIndex(evtX))); } isShowList = false; } this.repaint(); } public void setIsCloseCurrent(boolean isCloseCurrent) { this.isCloseCurrent = isCloseCurrent; } /** * 关闭模板 * @param specifiedTemplate 模板 */ public void closeSpecifiedTemplate(JTemplate specifiedTemplate) { if (specifiedTemplate == null) { return; } //当前激活的模板 String filename = openedTemplate.get(selectedIndex).getEditingFILE().getPath(); if (filename.startsWith(ProjectConstants.REPORTLETS_NAME)) { filename = ((FileNodeFILE) openedTemplate.get(selectedIndex).getEditingFILE()).getEnvPath() + File.separator + filename; } filename = filename.replaceAll("/", "\\\\"); if (!specifiedTemplate.isALLSaved()) { specifiedTemplate.stopEditing(); int returnVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("Utils-Would_you_like_to_save") + " \"" + specifiedTemplate.getEditingFILE() + "\" ?", ProductConstants.PRODUCT_NAME, JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (returnVal == JOptionPane.YES_OPTION && specifiedTemplate.saveTemplate()) { specifiedTemplate.saveTemplate(); FRLogger.getLogger().log(Level.INFO, Inter.getLocText(new String[]{"Template", "already-saved"}, new String[]{specifiedTemplate.getEditingFILE().getName(), "."})); HistoryTemplateListPane.getInstance().closeSelectedReport(specifiedTemplate); activeTemplate(filename); } else if (returnVal == JOptionPane.NO_OPTION) { //不保存 HistoryTemplateListPane.getInstance().closeSelectedReport(specifiedTemplate); activeTemplate(filename); } //若是点击取消关闭,则什么都不做 } else { //若是已经保存过了,则关闭即可 HistoryTemplateListPane.getInstance().closeSelectedReport(specifiedTemplate); activeTemplate(filename); } } /** * 关闭模板 * @param closedTemplate 模板 */ public void closeFormat(JTemplate closedTemplate) { //表单不需要处理 if (!closedTemplate.isJWorkBook()) { return; } if (DesignerContext.getFormatState() == DesignerContext.FORMAT_STATE_NULL) { return; } //是被参照的模板被关闭,则重置格式刷 closedTemplate.doConditionCancelFormat(); } /** * 关闭掉一个模板之后该激活的Tab * * @param fileName */ private void activeTemplate(String fileName) { if (openedTemplate.isEmpty()) { //新建并激活模板 DesignerContext.getDesignerFrame().addAndActivateJTemplate(); selectedIndex = 0; //此时刚自动新建的模板在HistoryTemplateListPane的editingTemplate temTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); } else { //如果关闭的模板是当前选中的模板,则重新激活 if (closeIconIndex == selectedIndex) { if (closeIconIndex == maxPaintIndex) { selectedIndex -= 1; } } else if (isCloseCurrent) { //不是通过关闭按钮,而是通过文件关闭菜单关闭的当前模板的,也重新激活 if (selectedIndex > openedTemplate.size() - 1) { selectedIndex -= 1; if (selectedIndex < 0) { selectedIndex = 0; } isCloseCurrent = false; } } else { //如果关闭的模板不是当前选中的模板,则激活的模板不变 selectedIndex = HistoryTemplateListPane.getInstance().contains(fileName); } DesignerContext.getDesignerFrame().activateJTemplate(openedTemplate.get(selectedIndex)); } } /** * 鼠标释放 * @param e 鼠标事件 */ public void mouseReleased(MouseEvent e) { } /** * 鼠标进入 * @param e 鼠标事件 */ public void mouseEntered(MouseEvent e) { } private boolean isOverCloseIcon(int evtX) { boolean isOverCloseIcon = false; for (int i = 0; i < startX.length; i++) { if (evtX >= startX[i] && evtX <= startX[i] + CLOSE.getIconWidth()) { isOverCloseIcon = true; break; } } return isOverCloseIcon; } private boolean isOverListDown(int evtX) { int maxWidth = getWidth() - LIST_BUTTON_WIDTH; return evtX >= (maxWidth + SMALLGAP) && evtX <= (getWidth() - SMALLGAP); } private int getTemplateIndex(int evtX) { int textX = 0; for (int i = minPaintIndex; i <= maxPaintIndex; i++) { int textWidth = realWidth; if (evtX >= textX && evtX < textX + textWidth) { return i; } textX += textWidth; } return -1; } /** * 鼠标离开 * @param e 鼠标事件 */ public void mouseExited(MouseEvent e) { listDownMode = LIST_DOWN; closeIconIndex = -1; mouseOveredIndex = -1; this.repaint(); } /** * 鼠标拖拽 * @param e 鼠标事件 */ public void mouseDragged(MouseEvent e) { } /** * 鼠标移动 * @param e 鼠标事件 */ public void mouseMoved(MouseEvent e) { int evtX = e.getX(); mouseOveredIndex = getTemplateIndex(evtX); //看是否需要显示toolTip if (mouseOveredIndex != -1 && isNeedToolTips[mouseOveredIndex - minPaintIndex]) { setToolTipText(openedTemplate.get(mouseOveredIndex).getEditingFILE().getName()); } else { setToolTipText(null); } listDownMode = isOverListDown(evtX) ? MOUSE_OVER_LIST_DOWN : LIST_DOWN; boolean isOverCloseIcon = isOverCloseIcon(evtX); clodeMode = isOverCloseIcon ? MOUSE_OVER_CLOSE : CLOSE; closeIconIndex = isOverCloseIcon ? mouseOveredIndex : -1; this.repaint(); } private void setPressedXY(int x, int y) { this.xyPressedCoordinate[0] = x; this.xyPressedCoordinate[1] = y; } public Object getValue(String key) { return null; } /** * 加入值 * @param key 键 * @param value 值 */ public void putValue(String key, Object value) { } /** * 动作 * @param e 事件 */ public void actionPerformed(ActionEvent e) { } /** * 处理自动新建的模板 在切换时的处理 */ public void doWithtemTemplate() { //temtemplate保存的一定是手动新建的没有编辑或是编辑了没有保存的模板 //没有保存,说明有编辑;已经保存在磁盘里的文件,说明有过处理,并且已经保存,此时切换都不将其自动关闭 if (temTemplate == null || temTemplate == HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()) { return; } if (!temTemplate.isSaved() || !temTemplate.getEditingFILE().isMemFile()) { temTemplate = null; } //自动新建的模板B若没有进行任何编辑(新建模板没有进行任何编辑时saved都是true):还没有存盘 if (temTemplate != null && temTemplate.getEditingFILE().isMemFile() && temTemplate.isSaved()) { HistoryTemplateListPane.getInstance().closeSelectedReport(temTemplate); temTemplate = null; setSelectedIndex(HistoryTemplateListPane.getInstance().contains(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate())); } } private class UIListDownItemUI extends BasicMenuItemUI { @Override protected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor) { if (menuItem.getIcon() == null) { super.paintBackground(g, menuItem, bgColor); return; } ButtonModel model = menuItem.getModel(); Color oldColor = g.getColor(); int menuWidth = menuItem.getWidth(); int menuHeight = menuItem.getHeight(); g.setColor(UIConstants.NORMAL_BACKGROUND); g.fillRect(0, 0, menuWidth, menuHeight); boolean itemIsSelected = menuItem instanceof JMenu && model.isSelected(); if (menuItem.isOpaque()) { if (model.isArmed() || itemIsSelected) { GUIPaintUtils.fillPaint((Graphics2D) g, GAP, 0, menuWidth - GAP, menuHeight, true, Constants.NULL, UIConstants.FLESH_BLUE, UIConstants.ARC); } else { GUIPaintUtils.fillPaint((Graphics2D) g, GAP, 0, menuWidth - GAP, menuHeight, true, Constants.NULL, menuItem.getBackground(), UIConstants.ARC); } g.setColor(oldColor); } else if (model.isArmed() || itemIsSelected) { GUIPaintUtils.fillPaint((Graphics2D) g, GAP, 0, menuWidth - GAP, menuHeight, true, Constants.NULL, UIConstants.FLESH_BLUE, UIConstants.ARC); g.setColor(oldColor); } } } } \ No newline at end of file +package com.fr.design.file; import java.awt.AWTEvent; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.awt.Font; import java.awt.GradientPaint; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.RenderingHints; import java.awt.Toolkit; import java.awt.event.AWTEventListener; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; import java.awt.geom.Arc2D; import java.awt.geom.GeneralPath; import java.awt.geom.Line2D; import java.awt.geom.Path2D; import java.awt.geom.RoundRectangle2D; import java.io.File; import java.util.logging.Level; import javax.swing.Action; import javax.swing.BorderFactory; import javax.swing.ButtonModel; import javax.swing.Icon; import javax.swing.JComponent; import javax.swing.JMenu; import javax.swing.JMenuItem; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JSeparator; import javax.swing.plaf.basic.BasicMenuItemUI; import com.fr.base.BaseUtils; import com.fr.base.GraphHelper; import com.fr.design.constants.UIConstants; import com.fr.design.gui.imenu.UIMenuItem; import com.fr.design.gui.imenu.UIScrollPopUpMenu; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.JTemplate; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUIPaintUtils; import com.fr.file.FILE; import com.fr.file.FileNodeFILE; import com.fr.general.ComparatorUtils; import com.fr.general.FRLogger; import com.fr.general.Inter; import com.fr.stable.Constants; import com.fr.stable.ProductConstants; import com.fr.stable.project.ProjectConstants; /** * Author : daisy * Date: 13-8-5 * Time: 下午6:12 */ public class MutilTempalteTabPane extends JComponent implements MouseListener, MouseMotionListener, Action { private static Icon LIST_DOWN = BaseUtils.readIcon("/com/fr/design/images/buttonicon/list_normal.png"); private static Icon MOUSE_OVER_LIST_DOWN = BaseUtils.readIcon("/com/fr/design/images/buttonicon/list_pressed.png"); private static Icon MOUSE_PRESS_LIST_DOWN = BaseUtils.readIcon("/com/fr/design/images/buttonicon/list_pressed.png"); private static Icon CLOSE = BaseUtils.readIcon("/com/fr/design/images/buttonicon/close_icon.png"); private static Icon MOUSE_OVER_CLOSE = BaseUtils.readIcon("/com/fr/design/images/buttonicon/mouseoverclose icon.png"); private static Icon MOUSE_PRESS_CLOSE = BaseUtils.readIcon("/com/fr/design/images/buttonicon/pressclose icon.png"); private static final String ELLIPSIS = "..."; private static final int GAP_BEFORE_CLOSE = 10; private static final int GAP = 5; private static final int SMALLGAP = 3; private static final int LIST_BUTTON_WIDTH = 34; private static final int HEIGHT = 26; private static final int LIST_DOWN_HEIGHT = 25; private static final double FOR_CAL_BYTES = 0.5; private static final double CORNOR_RADIUS = 0.0; //选了30度和60度的特殊角度的x,y作为经过的两个点的坐标 private static final double SPECIAL_LOCATION_1 = 2.5; private static final double SPECIAL_LOCATION_2 = 4.330127; private static final int ICON_WIDTH = 22; //每个标签页的最大的长度和最小长度。这些长度均为均分 private static final int MAXWIDTH = 240; private static final int MINWIDTH = 100; private static MutilTempalteTabPane THIS; //用于存放工作簿 private java.util.List> openedTemplate; //选中的Tab项 private int selectedIndex = 0; // private int mouseOveredIndex = -1; //tab栏可以放下的每个tab的实际宽度 private int realWidth = MAXWIDTH; //当前标签页栏存放的所有标签页的index private int minPaintIndex = 0; private int maxPaintIndex = 0; /** * 鼠标按下时的坐标数组、鼠标放开时的坐标数组 */ private int[] xyPressedCoordinate = {0, 0}; //每个关闭图标的起始位置 private int[] startX; private boolean[] isNeedToolTips; private Graphics2D g2d; //记录关闭按钮的状态 private int closeIconIndex = -1; private boolean isCloseCurrent = false; private Icon clodeMode = CLOSE; private Icon listDownMode = LIST_DOWN; private boolean isShowList = false; //自动新建的模板B若没有进行任何编辑,切换到其他 // // 模板时,模板B会自动关闭 private JTemplate temTemplate = null; private AWTEventListener awt = new AWTEventListener() { public void eventDispatched(AWTEvent event) { if (event instanceof MouseEvent) { MouseEvent mv = (MouseEvent) event; if (mv.getClickCount() > 0 && !ComparatorUtils.equals(mv.getSource(), MutilTempalteTabPane.this)) { isShowList = false; } } } }; public static final MutilTempalteTabPane getInstance() { if (THIS == null) { THIS = new MutilTempalteTabPane(); } return THIS; } public JTemplate getSelectedFile() { return openedTemplate.get(selectedIndex); } /** * 关闭掉当前已打开文件列表中指定的文件 * * @param file 指定的文件 * */ public void closeFileTemplate(FILE file){ for (JTemplate temp : openedTemplate) { if(ComparatorUtils.equals(file, temp.getEditingFILE())){ closeSpecifiedTemplate(temp); break; } } } public Dimension getPreferredSize() { Dimension dimension = super.getPreferredSize(); dimension.height = HEIGHT; return dimension; } /** * 多工作簿面板 */ public MutilTempalteTabPane() { this.setLayout(new BorderLayout(0, 0)); this.addMouseListener(this); this.addMouseMotionListener(this); this.setBorder(null); this.setForeground(new Color(99, 99, 99)); this.setFont(new Font(Inter.getLocText("FR-Designer_Song_TypeFace"), 0, 12)); openedTemplate = HistoryTemplateListPane.getInstance().getHistoryList(); selectedIndex = openedTemplate.size() - 1; Toolkit.getDefaultToolkit().addAWTEventListener(awt, AWTEvent.MOUSE_EVENT_MASK); } private UIMenuItem initCloseOther() { UIMenuItem closeOther = new UIMenuItem(Inter.getLocText("FR-Designer_FS_Close_Other_Templates")); setListDownItemPreferredSize(closeOther); closeOther.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (openedTemplate.size() == 1) { return; } SaveSomeTemplatePane saveSomeTempaltePane = new SaveSomeTemplatePane(false); //点击关闭其他模板,并且点击确定保存 if (saveSomeTempaltePane.showSavePane()) { JTemplate[] panes = new JTemplate[openedTemplate.size()]; for(int i = 0; i < openedTemplate.size(); i++) { panes[i] = openedTemplate.get(i); } for (int i = 0; i < panes.length; i++) { if (i != selectedIndex) { //判断关闭的模板是不是格式刷的被参照的模板 openedTemplate.remove(panes[i]); closeFormat(panes[i]); HistoryTemplateListPane.getInstance().closeSelectedReport(panes[i]); } } JTemplate currentTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); HistoryTemplateListPane.getInstance().removeAllHistory(); DesignerContext.getDesignerFrame().activateJTemplate(currentTemplate); THIS.repaint(); } //如果取消保存了,则不关闭其他模板 } }); if (openedTemplate.size() == 1) { closeOther.setEnabled(false); } return closeOther; } private UIMenuItem[] createListDownTemplate() { UIMenuItem[] templates = new UIMenuItem[openedTemplate.size()]; for (int i = 0; i < openedTemplate.size(); i++) { final int index = i; final JTemplate tem = openedTemplate.get(i); templates[i] = new UIMenuItem(tempalteShowName(tem), tem.getIcon()); templates[i].setUI(new UIListDownItemUI()); setListDownItemPreferredSize(templates[i]); if (i == selectedIndex) { //画选中的高亮 templates[i].setBackground(UIConstants.SHADOW_CENTER); } templates[i].addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { selectedIndex = index; DesignerContext.getDesignerFrame().addAndActivateJTemplate(tem); } }); } return templates; } private void setListDownItemPreferredSize(UIMenuItem item) { Dimension dimension = item.getPreferredSize(); dimension.height = LIST_DOWN_HEIGHT; item.setPreferredSize(dimension); } private String tempalteShowName(JTemplate template) { String name = template.getEditingFILE().getName(); if (!template.isSaved() && !name.endsWith(" *")) { name += " *"; } return name; } /** * 刷新打开模板 * @param history 模板 */ public void refreshOpenedTemplate(java.util.List> history) { openedTemplate = history; } public void setTemTemplate(JTemplate auotCreate) { temTemplate = auotCreate; } private void showListDown() { UIScrollPopUpMenu menu = new UIScrollPopUpMenu(); menu.setBorder(BorderFactory.createEmptyBorder(-3, 3, 3, 0)); menu.add(initCloseOther()); JSeparator separator = new JSeparator() { public Dimension getPreferredSize() { Dimension d = super.getPreferredSize(); d.height = 1; return d; } }; menu.add(new JPanel() { public Dimension getPreferredSize() { Dimension d = super.getPreferredSize(); d.height = 1; return d; } }); separator.setForeground(UIConstants.LINE_COLOR); menu.add(separator); menu.add(new JPanel() { public Dimension getPreferredSize() { Dimension d = super.getPreferredSize(); d.height = 1; return d; } }); UIMenuItem[] items = createListDownTemplate(); for (int i = 0; i < items.length; i++) { menu.add(items[i]); } GUICoreUtils.showPopupMenu(menu, MutilTempalteTabPane.getInstance(), MutilTempalteTabPane.getInstance().getWidth() - menu.getPreferredSize().width, getY() - 1 + getHeight()); } public void setSelectedIndex(int index) { selectedIndex = index; } public void paintComponent(Graphics g) { super.paintComponent(g); double maxWidth = getWidth() - LIST_BUTTON_WIDTH; //最大宽度 g2d = (Graphics2D) g; paintBackgroundAndLine(g2d, maxWidth); } private void paintBackgroundAndLine(Graphics2D g2d, double maxWidth) { paintDefaultBackground(g2d); //最多能画的个数 int maxTemplateNum = (int) (maxWidth) / MINWIDTH; //计算开始画的最小模板index和最大模板index calMinAndMaxIndex(maxTemplateNum); calculateRealAverageWidth(maxWidth, maxTemplateNum); int maxStringlength = calculateStringMaxLength(); if (selectedIndex >= openedTemplate.size()) { selectedIndex = openedTemplate.size() - 1; } if (selectedIndex < 0) { selectedIndex = 0; } double templateStartX = 0; startX = new int[maxPaintIndex - minPaintIndex + 1]; isNeedToolTips = new boolean[maxPaintIndex - minPaintIndex + 1]; //从可以开始展示在tab面板上的tab开始画 for (int i = minPaintIndex; i <= maxPaintIndex; i++) { JTemplate template = openedTemplate.get(i); Icon icon = template.getIcon(); String name = tempalteShowName(template); //如果tab名字的长度大于最大能显示的英文字符长度,则进行省略号处理 if (getStringWidth(name) > maxStringlength) { name = getEllipsisName(name, maxStringlength); isNeedToolTips[i - minPaintIndex] = true; } else { isNeedToolTips[i - minPaintIndex] = false; } Icon selectedIcon = null; if (i == closeIconIndex) { selectedIcon = clodeMode; } else { selectedIcon = CLOSE; } if (i == selectedIndex) { startX[i - minPaintIndex] = paintSelectedTab(g2d, icon, templateStartX, name, selectedIcon); } else { boolean isLeft = i < selectedIndex; startX[i - minPaintIndex] = paintUnSelectedTab(g2d, icon, templateStartX, name, selectedIcon, isLeft, mouseOveredIndex, i); } templateStartX += realWidth; } paintListDown(g2d, maxWidth); paintUnderLine(templateStartX, maxWidth, g2d); } private void paintUnderLine(double templateStartX, double maxWidth, Graphics2D g2d) { //画下面的那条线 if (templateStartX < maxWidth) { GeneralPath generalPath = new GeneralPath(Path2D.WIND_EVEN_ODD, 2); generalPath.moveTo((float) templateStartX, getHeight() - 1); generalPath.lineTo((float) maxWidth, getHeight() - 1); g2d.fill(generalPath); g2d.setPaint(UIConstants.LINE_COLOR); g2d.draw(new Line2D.Double((float) templateStartX, getHeight() - 1, (float) maxWidth + LIST_BUTTON_WIDTH, getHeight() - 1)); } } private void paintDefaultBackground(Graphics2D g2d) { //画默认背景 g2d.setPaint(new GradientPaint(1, 1, UIConstants.SHADOW_GREY, 1, getHeight() - 1, UIConstants.SHADOW_GREY)); g2d.fillRect(getX(), getY(), getWidth(), getHeight()); } private void paintListDown(Graphics2D g2d, double maxWidth) { int x = (int) maxWidth + (LIST_BUTTON_WIDTH - listDownMode.getIconWidth()) / 2; int y = (getHeight() - listDownMode.getIconHeight()) / 2; listDownMode.paintIcon(this, g2d, x, y); } /** * 判断tab文字的长度大于能装下的最大文字长度,要用省略号 * * @param name * @param maxStringlength * @return */ private String getEllipsisName(String name, int maxStringlength) { //若是名字长度大于能显示的长度,那能显示的文字的最大长度还要减去省略号的最大长度 // int maxellipsislength = maxStringlength - ELLIPSIS.length(); int ellipsisWidth = getStringWidth(ELLIPSIS); int leftkeyPoint = 0; int rightKeyPoint = name.length() - 1; int leftStrWidth = 0; int rightStrWidth = 0; while (leftStrWidth + rightStrWidth + ellipsisWidth < maxStringlength) { if (leftStrWidth <= rightStrWidth) { leftkeyPoint++; } else { rightKeyPoint--; } leftStrWidth = getStringWidth(name.substring(0, leftkeyPoint)); rightStrWidth = getStringWidth(name.substring(rightKeyPoint)); if (leftStrWidth + rightStrWidth + ellipsisWidth > maxStringlength) { if (leftStrWidth <= rightStrWidth) { rightKeyPoint++; } break; } } return name.substring(0, leftkeyPoint) + ELLIPSIS + name.substring(rightKeyPoint); } private void calMinAndMaxIndex(int maxTemplateNum) { //如果个数大于最多能容纳的个数,则多余的进行处理 if (openedTemplate.size() > maxTemplateNum) { //所点击列表中的标签页处在标签页栏最后一个标签页之后,则标签页栏左移至所点击标签页出现 if (selectedIndex >= maxPaintIndex) { minPaintIndex = selectedIndex - maxTemplateNum + 1; maxPaintIndex = selectedIndex; if (minPaintIndex <= 0) { minPaintIndex = 0; maxPaintIndex = maxTemplateNum - 1; } } else if (selectedIndex <= minPaintIndex) { //所点击列表中的标签页处在标签页栏第一个标签页之前,则标签页栏右移至所点击标签页出现 minPaintIndex = selectedIndex; maxPaintIndex = minPaintIndex + maxTemplateNum - 1; if (maxPaintIndex > openedTemplate.size() - 1) { maxPaintIndex = openedTemplate.size() - 1; } } else { if (selectedIndex >= openedTemplate.size() - 1) { selectedIndex = openedTemplate.size() - 1; maxPaintIndex = selectedIndex; minPaintIndex = selectedIndex - maxTemplateNum + 1; } else { maxPaintIndex = minPaintIndex + maxTemplateNum - 1; if (maxPaintIndex > openedTemplate.size() - 1) { maxPaintIndex = openedTemplate.size() - 1; } } } } else { minPaintIndex = 0; maxPaintIndex = openedTemplate.size() - 1; } } //个数小于最多能容纳的个数的情况下,看看宽度每个要画多少 private void calculateRealAverageWidth(double maxwidth, int templateNum) { int num = openedTemplate.size() > templateNum ? templateNum : openedTemplate.size(); realWidth = (int) (maxwidth / (num)); if (realWidth > MAXWIDTH) { realWidth = MAXWIDTH; } else if (realWidth < MINWIDTH) { //平均下来每个的宽度小于最小宽度 realWidth = MINWIDTH; } } /** * 计算过长度之后的每个tab的能接受的文字的英文字符数 * * @return */ private int calculateStringMaxLength() { return realWidth - 3 * GAP - ICON_WIDTH - SMALLGAP - CLOSE.getIconWidth(); } private int getStringWidth(String str) { return GraphHelper.getFontMetrics(this.getFont()).stringWidth(str); } /** * 画选中的tab * * @param g2d * @param sheeticon * @param templateStartX * @param sheetName * @param closeIcon * @return */ private int paintSelectedTab(Graphics2D g2d, Icon sheeticon, double templateStartX, String sheetName, Icon closeIcon) { double[] x = {templateStartX, templateStartX, templateStartX + realWidth, templateStartX + realWidth, templateStartX}; double[] y = {-1, getHeight(), getHeight(), -1, -1}; RoundRectangle2D.Double rect1 = new RoundRectangle2D.Double(templateStartX, 1, this.getWidth(), this.getHeight(), 7, 7); g2d.setPaint(new GradientPaint(1, 1, UIConstants.NORMAL_BACKGROUND, 1, getHeight() - 1, UIConstants.NORMAL_BACKGROUND)); //选了30度和60度的特殊角度的x,y作为经过的两个点的坐标 double specialLocation1 = 2.5; double specialLocation2 = 4.330127; GeneralPath generalPath = new GeneralPath(Path2D.WIND_EVEN_ODD, x.length); generalPath.moveTo((float) x[0] + CORNOR_RADIUS, (float) y[0]); generalPath.curveTo(((float) x[0] + CORNOR_RADIUS - specialLocation1), (y[0] + CORNOR_RADIUS - specialLocation2), ((float) x[0] + CORNOR_RADIUS - specialLocation2), (y[0] + CORNOR_RADIUS - specialLocation1), x[0], y[0] + CORNOR_RADIUS); for (int index = 1; index <= 2; index++) { generalPath.lineTo((float) x[index], (float) y[index]); } generalPath.lineTo((float) x[3], (float) y[3] + CORNOR_RADIUS); generalPath.curveTo(((float) x[3] - CORNOR_RADIUS + specialLocation1), ((float) y[3] + CORNOR_RADIUS - specialLocation2), ((float) x[3] - CORNOR_RADIUS + specialLocation2), ((float) y[3] + CORNOR_RADIUS - specialLocation1), (float) x[3] - CORNOR_RADIUS, (float) y[3]); generalPath.lineTo((float) x[0] + CORNOR_RADIUS, (float) y[0]); generalPath.closePath(); g2d.fill(generalPath); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setPaint(UIConstants.LINE_COLOR); g2d.draw(new Arc2D.Double(x[0], y[0], CORNOR_RADIUS * 2, CORNOR_RADIUS * 2, 90, 90, 0)); g2d.draw(new Line2D.Double(x[0], y[0] + CORNOR_RADIUS, x[1], y[1])); g2d.draw(new Line2D.Double(x[1], y[1], x[2], y[2])); g2d.draw(new Line2D.Double(x[2], y[2], x[3], y[3] + CORNOR_RADIUS)); g2d.draw(new Arc2D.Double(x[3] - CORNOR_RADIUS * 2, y[3], CORNOR_RADIUS * 2, CORNOR_RADIUS * 2, 90, -90, 0)); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); int sheetIconY = (getHeight() - sheeticon.getIconHeight()) / 2; sheeticon.paintIcon(this, g2d, (int) templateStartX + GAP, sheetIconY); // 画字符 g2d.setPaint(getForeground()); g2d.drawString(sheetName, (int) templateStartX + sheeticon.getIconWidth() + 2 * GAP, getHeight() - GAP * 2); int closePosition = (int) templateStartX + realWidth - CLOSE.getIconWidth() - SMALLGAP; int closeY = (getHeight() - closeIcon.getIconHeight()) / 2; closeIcon.paintIcon(this, g2d, closePosition, closeY); return closePosition; } /** * 画没有选中的tab * * @param g2d * @param sheeticon * @param templateStartX * @param sheetName * @param closeIcon * @param isLeft * @return */ private int paintUnSelectedTab(Graphics2D g2d, Icon sheeticon, double templateStartX, String sheetName, Icon closeIcon, boolean isLeft, int mouseOveredIndex, int selfIndex) { double[] x = {templateStartX, templateStartX, templateStartX + realWidth, templateStartX + realWidth, templateStartX}; double[] y = {-1, getHeight() - 1, getHeight() - 1, -1, -1}; if (selfIndex == mouseOveredIndex) { g2d.setPaint(new GradientPaint(1, 1, UIConstants.HOVER_BLUE, 1, getHeight() - 1, UIConstants.HOVER_BLUE)); } else { g2d.setPaint(new GradientPaint(1, 1, UIConstants.SHADOW_GREY, 1, getHeight() - 1, UIConstants.SHADOW_GREY)); } GeneralPath generalPath = new GeneralPath(Path2D.WIND_EVEN_ODD, x.length); unSelectedClosedPath(generalPath, isLeft, x, y); g2d.fill(generalPath); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setPaint(UIConstants.LINE_COLOR); if (isLeft) { g2d.draw(new Arc2D.Double(x[0], y[0], CORNOR_RADIUS * 2, CORNOR_RADIUS * 2, 90, 90, 0)); } else { g2d.draw(new Arc2D.Double(x[0] - CORNOR_RADIUS * 2, y[0], CORNOR_RADIUS * 2, CORNOR_RADIUS * 2, 90, -90, 0)); } g2d.draw(new Line2D.Double(x[0], y[0] + CORNOR_RADIUS, x[1], y[1] + 1)); g2d.draw(new Line2D.Double(x[1], y[1], x[2], y[2])); g2d.draw(new Line2D.Double(x[2], y[2], x[3], y[3] + CORNOR_RADIUS)); if (isLeft) { g2d.draw(new Arc2D.Double(x[3], y[3], CORNOR_RADIUS * 2, CORNOR_RADIUS * 2, 90, 90, 0)); } else { g2d.draw(new Arc2D.Double(x[3] - CORNOR_RADIUS * 2, y[3], CORNOR_RADIUS * 2, CORNOR_RADIUS * 2, 90, -90, 0)); } g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); int sheetIconY = (getHeight() - sheeticon.getIconHeight()) / 2; sheeticon.paintIcon(this, g2d, (int) templateStartX + GAP, sheetIconY); // 画字符 g2d.setPaint(getForeground()); g2d.drawString(sheetName, (int) templateStartX + sheeticon.getIconWidth() + 2 * GAP, getHeight() - GAP * 2); int closeY = (getHeight() - closeIcon.getIconHeight()) / 2; int closePosition = (int) templateStartX + realWidth - CLOSE.getIconWidth() - SMALLGAP; closeIcon.paintIcon(this, g2d, closePosition, closeY); return closePosition; } private void unSelectedClosedPath(GeneralPath generalPath, boolean isLeft, double[] x, double[] y) { if (isLeft) { generalPath.moveTo((float) x[0] + CORNOR_RADIUS, (float) y[0]); generalPath.curveTo(((float) x[0] + CORNOR_RADIUS - SPECIAL_LOCATION_1), (y[0] + CORNOR_RADIUS - SPECIAL_LOCATION_2), ((float) x[0] + CORNOR_RADIUS - SPECIAL_LOCATION_2), (y[0] + CORNOR_RADIUS - SPECIAL_LOCATION_1), x[0], y[0] + CORNOR_RADIUS); } else { generalPath.moveTo((float) x[0] - CORNOR_RADIUS, (float) y[0]); generalPath.curveTo(((float) x[0] - CORNOR_RADIUS + SPECIAL_LOCATION_1), (y[0] + CORNOR_RADIUS - SPECIAL_LOCATION_2), ((float) x[0] - CORNOR_RADIUS + SPECIAL_LOCATION_2), (y[0] + CORNOR_RADIUS - SPECIAL_LOCATION_1), x[0], y[0] + CORNOR_RADIUS); } for (int index = 1; index <= 2; index++) { generalPath.lineTo((float) x[index], (float) y[index]); } generalPath.lineTo((float) x[3], (float) y[3] + CORNOR_RADIUS); if (isLeft) { generalPath.curveTo(((float) x[3] + CORNOR_RADIUS - SPECIAL_LOCATION_1), ((float) y[3] + CORNOR_RADIUS - SPECIAL_LOCATION_2), ((float) x[3] + CORNOR_RADIUS - SPECIAL_LOCATION_2), ((float) y[3] - CORNOR_RADIUS + SPECIAL_LOCATION_1), (float) x[3] + CORNOR_RADIUS, (float) y[3]); generalPath.lineTo((float) x[0] + CORNOR_RADIUS, (float) y[0]); } else { generalPath.curveTo(((float) x[3] - CORNOR_RADIUS + SPECIAL_LOCATION_1), ((float) y[3] + CORNOR_RADIUS - SPECIAL_LOCATION_2), ((float) x[3] - CORNOR_RADIUS + SPECIAL_LOCATION_2), ((float) y[3] + CORNOR_RADIUS - SPECIAL_LOCATION_1), (float) x[3] - CORNOR_RADIUS, (float) y[3]); generalPath.lineTo((float) x[0] - CORNOR_RADIUS, (float) y[0]); } generalPath.closePath(); } /** * 点击 * @param e 鼠标事件 */ public void mouseClicked(MouseEvent e) { } /** * 按下 * @param e 鼠标事件 */ public void mousePressed(MouseEvent e) { int evtX = e.getX(); int evtY = e.getY(); this.setPressedXY(evtX, evtY); //是否点击关闭按钮 如果点击了关闭按钮,则将点击的模板关闭,不需要切换,如果没有点击关闭按钮,则切换到点击的模板处 boolean isOverCloseIcon = isOverCloseIcon(evtX); if (isOverListDown(evtX)) { listDownMode = isOverListDown(evtX) ? MOUSE_PRESS_LIST_DOWN : LIST_DOWN; if (!isShowList) { showListDown(); } isShowList = !isShowList; } else if (isOverCloseIcon) { //关闭按钮的图标变化 closeIconIndex = getTemplateIndex(evtX); clodeMode = MOUSE_PRESS_CLOSE; //关闭close图标所在的模板{ closeFormat(openedTemplate.get(closeIconIndex)); closeSpecifiedTemplate(openedTemplate.get(closeIconIndex)); DesignerContext.getDesignerFrame().getContentFrame().repaint(); isShowList = false; } else { //没有点击关闭和ListDown按钮,则切换到点击的模板处 closeIconIndex = -1; clodeMode = CLOSE; int tempSelectedIndex = selectedIndex; if (selectedIndex != getTemplateIndex(evtX) && getTemplateIndex(evtX) != -1) { openedTemplate.get(selectedIndex).stopEditing(); selectedIndex = getTemplateIndex(evtX); //如果在权限编辑情况下,不允许切换到表单类型的工作簿 if(BaseUtils.isAuthorityEditing() && !openedTemplate.get(selectedIndex).isJWorkBook()){ DesignerContext.getDesignerFrame().addAndActivateJTemplate(openedTemplate.get(tempSelectedIndex)); JOptionPane.showMessageDialog(this, Inter.getLocText("FR-Designer_Form-AuthorityEdited_Cannot_be_Supported") + "!", Inter.getLocText("FR-Designer_Alert"), JOptionPane.WARNING_MESSAGE); this.repaint(); return; } DesignerContext.getDesignerFrame().addAndActivateJTemplate(openedTemplate.get(getTemplateIndex(evtX))); } isShowList = false; } this.repaint(); } public void setIsCloseCurrent(boolean isCloseCurrent) { this.isCloseCurrent = isCloseCurrent; } /** * 关闭模板 * @param specifiedTemplate 模板 */ public void closeSpecifiedTemplate(JTemplate specifiedTemplate) { if (specifiedTemplate == null) { return; } //当前激活的模板 String filename = openedTemplate.get(selectedIndex).getEditingFILE().getPath(); if (filename.startsWith(ProjectConstants.REPORTLETS_NAME)) { filename = ((FileNodeFILE) openedTemplate.get(selectedIndex).getEditingFILE()).getEnvPath() + File.separator + filename; } filename = filename.replaceAll("/", "\\\\"); if (!specifiedTemplate.isALLSaved()) { specifiedTemplate.stopEditing(); int returnVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("Utils-Would_you_like_to_save") + " \"" + specifiedTemplate.getEditingFILE() + "\" ?", ProductConstants.PRODUCT_NAME, JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (returnVal == JOptionPane.YES_OPTION && specifiedTemplate.saveTemplate()) { specifiedTemplate.saveTemplate(); FRLogger.getLogger().log(Level.INFO, Inter.getLocText(new String[]{"Template", "already-saved"}, new String[]{specifiedTemplate.getEditingFILE().getName(), "."})); HistoryTemplateListPane.getInstance().closeSelectedReport(specifiedTemplate); activeTemplate(filename); } else if (returnVal == JOptionPane.NO_OPTION) { //不保存 HistoryTemplateListPane.getInstance().closeSelectedReport(specifiedTemplate); activeTemplate(filename); } //若是点击取消关闭,则什么都不做 } else { //若是已经保存过了,则关闭即可 HistoryTemplateListPane.getInstance().closeSelectedReport(specifiedTemplate); activeTemplate(filename); } } /** * 关闭模板 * @param closedTemplate 模板 */ public void closeFormat(JTemplate closedTemplate) { //表单不需要处理 if (!closedTemplate.isJWorkBook()) { return; } if (DesignerContext.getFormatState() == DesignerContext.FORMAT_STATE_NULL) { return; } //是被参照的模板被关闭,则重置格式刷 closedTemplate.doConditionCancelFormat(); } /** * 关闭掉一个模板之后该激活的Tab * * @param fileName */ private void activeTemplate(String fileName) { if (openedTemplate.isEmpty()) { //新建并激活模板 DesignerContext.getDesignerFrame().addAndActivateJTemplate(); selectedIndex = 0; //此时刚自动新建的模板在HistoryTemplateListPane的editingTemplate temTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); } else { //如果关闭的模板是当前选中的模板,则重新激活 if (closeIconIndex == selectedIndex) { if (closeIconIndex == maxPaintIndex) { selectedIndex --; } } else if (isCloseCurrent) { //不是通过关闭按钮,而是通过文件关闭菜单关闭的当前模板的,也重新激活 if (selectedIndex > openedTemplate.size() - 1) { selectedIndex -= 1; if (selectedIndex < 0) { selectedIndex = 0; } isCloseCurrent = false; } } else { //如果关闭的模板不是当前选中的模板,则激活的模板不变 selectedIndex = HistoryTemplateListPane.getInstance().contains(fileName); } DesignerContext.getDesignerFrame().activateJTemplate(openedTemplate.get(selectedIndex)); } } /** * 鼠标释放 * @param e 鼠标事件 */ public void mouseReleased(MouseEvent e) { } /** * 鼠标进入 * @param e 鼠标事件 */ public void mouseEntered(MouseEvent e) { } private boolean isOverCloseIcon(int evtX) { boolean isOverCloseIcon = false; for (int i = 0; i < startX.length; i++) { if (evtX >= startX[i] && evtX <= startX[i] + CLOSE.getIconWidth()) { isOverCloseIcon = true; break; } } return isOverCloseIcon; } private boolean isOverListDown(int evtX) { int maxWidth = getWidth() - LIST_BUTTON_WIDTH; return evtX >= (maxWidth + SMALLGAP) && evtX <= (getWidth() - SMALLGAP); } private int getTemplateIndex(int evtX) { int textX = 0; for (int i = minPaintIndex; i <= maxPaintIndex; i++) { int textWidth = realWidth; if (evtX >= textX && evtX < textX + textWidth) { return i; } textX += textWidth; } return -1; } /** * 鼠标离开 * @param e 鼠标事件 */ public void mouseExited(MouseEvent e) { listDownMode = LIST_DOWN; closeIconIndex = -1; mouseOveredIndex = -1; this.repaint(); } /** * 鼠标拖拽 * @param e 鼠标事件 */ public void mouseDragged(MouseEvent e) { } /** * 鼠标移动 * @param e 鼠标事件 */ public void mouseMoved(MouseEvent e) { int evtX = e.getX(); mouseOveredIndex = getTemplateIndex(evtX); //看是否需要显示toolTip if (mouseOveredIndex != -1 && isNeedToolTips[mouseOveredIndex - minPaintIndex]) { setToolTipText(openedTemplate.get(mouseOveredIndex).getEditingFILE().getName()); } else { setToolTipText(null); } listDownMode = isOverListDown(evtX) ? MOUSE_OVER_LIST_DOWN : LIST_DOWN; boolean isOverCloseIcon = isOverCloseIcon(evtX); clodeMode = isOverCloseIcon ? MOUSE_OVER_CLOSE : CLOSE; closeIconIndex = isOverCloseIcon ? mouseOveredIndex : -1; this.repaint(); } private void setPressedXY(int x, int y) { this.xyPressedCoordinate[0] = x; this.xyPressedCoordinate[1] = y; } public Object getValue(String key) { return null; } /** * 加入值 * @param key 键 * @param value 值 */ public void putValue(String key, Object value) { } /** * 动作 * @param e 事件 */ public void actionPerformed(ActionEvent e) { } /** * 处理自动新建的模板 在切换时的处理 */ public void doWithtemTemplate() { //temtemplate保存的一定是手动新建的没有编辑或是编辑了没有保存的模板 //没有保存,说明有编辑;已经保存在磁盘里的文件,说明有过处理,并且已经保存,此时切换都不将其自动关闭 if (temTemplate == null || temTemplate == HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()) { return; } if (!temTemplate.isSaved() || !temTemplate.getEditingFILE().isMemFile()) { temTemplate = null; } //自动新建的模板B若没有进行任何编辑(新建模板没有进行任何编辑时saved都是true):还没有存盘 if (temTemplate != null && temTemplate.getEditingFILE().isMemFile() && temTemplate.isSaved()) { HistoryTemplateListPane.getInstance().closeSelectedReport(temTemplate); temTemplate = null; setSelectedIndex(HistoryTemplateListPane.getInstance().contains(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate())); } } private class UIListDownItemUI extends BasicMenuItemUI { @Override protected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor) { if (menuItem.getIcon() == null) { super.paintBackground(g, menuItem, bgColor); return; } ButtonModel model = menuItem.getModel(); Color oldColor = g.getColor(); int menuWidth = menuItem.getWidth(); int menuHeight = menuItem.getHeight(); g.setColor(UIConstants.NORMAL_BACKGROUND); g.fillRect(0, 0, menuWidth, menuHeight); boolean itemIsSelected = menuItem instanceof JMenu && model.isSelected(); if (menuItem.isOpaque()) { if (model.isArmed() || itemIsSelected) { GUIPaintUtils.fillPaint((Graphics2D) g, GAP, 0, menuWidth - GAP, menuHeight, true, Constants.NULL, UIConstants.FLESH_BLUE, UIConstants.ARC); } else { GUIPaintUtils.fillPaint((Graphics2D) g, GAP, 0, menuWidth - GAP, menuHeight, true, Constants.NULL, menuItem.getBackground(), UIConstants.ARC); } g.setColor(oldColor); } else if (model.isArmed() || itemIsSelected) { GUIPaintUtils.fillPaint((Graphics2D) g, GAP, 0, menuWidth - GAP, menuHeight, true, Constants.NULL, UIConstants.FLESH_BLUE, UIConstants.ARC); g.setColor(oldColor); } } } } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/fun/ElementUIProvider.java b/designer_base/src/com/fr/design/fun/ElementUIProvider.java index 9f93c21ed3..7cdd8eb721 100644 --- a/designer_base/src/com/fr/design/fun/ElementUIProvider.java +++ b/designer_base/src/com/fr/design/fun/ElementUIProvider.java @@ -31,7 +31,7 @@ public interface ElementUIProvider extends Mutable { * 右侧的快速编辑器 * @return 编辑器 */ - QuickEditor quickEditor(); + Class quickEditor(); /** * 插件单元格元素 diff --git a/designer_base/src/com/fr/design/gui/chart/BaseChartPropertyPane.java b/designer_base/src/com/fr/design/gui/chart/BaseChartPropertyPane.java index 2bedd08dbe..c5b58ae268 100644 --- a/designer_base/src/com/fr/design/gui/chart/BaseChartPropertyPane.java +++ b/designer_base/src/com/fr/design/gui/chart/BaseChartPropertyPane.java @@ -20,6 +20,8 @@ public abstract class BaseChartPropertyPane extends DockingView { public abstract void setSupportCellData(boolean supportCellData); public abstract void populateChartPropertyPane(BaseChartCollection collection, TargetComponent ePane); - - public abstract void setWidgetPropertyPane(BaseWidgetPropertyPane pane); + + public abstract ChartEditPaneProvider getChartEditPane(); + + //public abstract void clear(); } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/gui/chart/ChartEditPaneProvider.java b/designer_base/src/com/fr/design/gui/chart/ChartEditPaneProvider.java new file mode 100644 index 0000000000..3d4119ab7f --- /dev/null +++ b/designer_base/src/com/fr/design/gui/chart/ChartEditPaneProvider.java @@ -0,0 +1,13 @@ +package com.fr.design.gui.chart; + +/** + * Created by daniel on 2016/11/2. + */ +public interface ChartEditPaneProvider { + + + void gotoPane(String... id); + + void fire(); + +} diff --git a/designer_base/src/com/fr/design/gui/frpane/UIComboBoxPane.java b/designer_base/src/com/fr/design/gui/frpane/UIComboBoxPane.java index e903aa95a0..99a126e127 100644 --- a/designer_base/src/com/fr/design/gui/frpane/UIComboBoxPane.java +++ b/designer_base/src/com/fr/design/gui/frpane/UIComboBoxPane.java @@ -153,4 +153,7 @@ public abstract class UIComboBoxPane extends BasicBeanPane { return this.cards; } + public void clear() { + reset(); + } } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/gui/itree/filetree/EnvFileTree.java b/designer_base/src/com/fr/design/gui/itree/filetree/EnvFileTree.java index 436ea911cf..c7d7676003 100644 --- a/designer_base/src/com/fr/design/gui/itree/filetree/EnvFileTree.java +++ b/designer_base/src/com/fr/design/gui/itree/filetree/EnvFileTree.java @@ -2,13 +2,11 @@ package com.fr.design.gui.itree.filetree; import java.awt.Component; import java.awt.Dimension; -import java.awt.dnd.DnDConstants; import java.io.File; import java.util.ArrayList; import java.util.Arrays; import com.fr.design.constants.UIConstants; -import com.fr.design.event.TemplateTreeDragSource; import com.fr.design.gui.ilable.UILabel; import javax.swing.JTree; import javax.swing.tree.DefaultTreeCellRenderer; @@ -74,7 +72,6 @@ public class EnvFileTree extends RefreshableJTree { this.setRootVisible(false); this.setShowsRootHandles(true); this.setEditable(false); - new TemplateTreeDragSource(this, DnDConstants.ACTION_COPY); } // CellRenderer diff --git a/designer_base/src/com/fr/design/mainframe/HelpDialogManager.java b/designer_base/src/com/fr/design/mainframe/HelpDialogManager.java index 9cae023ea7..5de971b71c 100644 --- a/designer_base/src/com/fr/design/mainframe/HelpDialogManager.java +++ b/designer_base/src/com/fr/design/mainframe/HelpDialogManager.java @@ -40,5 +40,6 @@ public class HelpDialogManager { if (handler != null) { handler.destroyHelpDialog(); } + handler = null; } } diff --git a/designer_base/src/com/fr/design/module/DesignModuleFactory.java b/designer_base/src/com/fr/design/module/DesignModuleFactory.java index b21d206c99..77233e4dbb 100644 --- a/designer_base/src/com/fr/design/module/DesignModuleFactory.java +++ b/designer_base/src/com/fr/design/module/DesignModuleFactory.java @@ -1 +1 @@ -package com.fr.design.module; import com.fr.base.FRContext; import com.fr.base.chart.BaseChartCollection; import com.fr.design.gui.chart.BaseChartPropertyPane; import com.fr.design.gui.chart.MiddleChartComponent; import com.fr.design.gui.chart.MiddleChartDialog; import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.core.WidgetOption; import com.fr.design.gui.frpane.BaseHyperlinkGroup; import com.fr.design.gui.frpane.HyperlinkGroupType; import com.fr.design.mainframe.BaseFormDesigner; import com.fr.design.mainframe.BaseWidgetPropertyPane; import com.fr.design.parameter.HierarchyTreePane; import com.fr.design.parameter.ParameterDesignerProvider; import com.fr.design.parameter.ParameterReader; import com.fr.form.ui.Widget; import com.fr.stable.StableUtils; import java.awt.*; import java.lang.reflect.Constructor; import java.util.ArrayList; /** * Created by IntelliJ IDEA. * Author : Richer * Version: 7.0.3 * Date: 13-7-8 * Time: 下午1:57 */ public class DesignModuleFactory { private static DesignModuleFactory instance = new DesignModuleFactory(); private DesignModuleFactory() { } private HyperlinkGroupType hyperlinkGroupType = new BaseHyperlinkGroup(); private NameableCreator[] creators4Hyperlink; private WidgetOption[] extraOptions; private Class chartEditorClass; private Class chartComponentClass; private Class chartDialogClass; private Class chartPropertyPaneClass; private Class newFormAction; private Class formParaDesigner; private Class paraPropertyPane; private Class formHierarchyPaneCls; private Class chartWidgetPropertyPaneCls; private Class widgetPropertyPane; private Class buttonDetailPaneClass; private java.util.List parameterReaderList; public static void registerHyperlinkGroupType(HyperlinkGroupType hyperlinkGroupType) { instance.hyperlinkGroupType = hyperlinkGroupType; } public static HyperlinkGroupType getHyperlinkGroupType() { return instance.hyperlinkGroupType; } public static void registerCreators4Hyperlink(NameableCreator[] nameableCreators) { instance.creators4Hyperlink = nameableCreators; } public static NameableCreator[] getCreators4Hyperlink() { return instance.creators4Hyperlink; } public static void registerExtraWidgetOptions(WidgetOption[] options) { instance.extraOptions = options; } public static WidgetOption[] getExtraWidgetOptions() { if (instance.extraOptions == null) { instance.extraOptions = new WidgetOption[0]; } return instance.extraOptions; } public static void registerChartEditorClass(Class cls) { instance.chartEditorClass = cls; } public static Class getChartEditorClass() { return instance.chartEditorClass; } public static void registerChartComponentClass(Class bcc) { instance.chartComponentClass = bcc; } public static void registerChartDialogClass(Class cd) { instance.chartDialogClass = cd; } public static void registerChartAndWidgetPropertyPane(Class p) { instance.chartWidgetPropertyPaneCls = p; } public static void registerChartPropertyPaneClass(Class p) { instance.chartPropertyPaneClass = p; } public static BaseChartPropertyPane getChartWidgetPropertyPane(BaseFormDesigner fd) { BaseChartPropertyPane p = null; if (instance.chartWidgetPropertyPaneCls != null) { p = StableUtils.getInstance(instance.chartWidgetPropertyPaneCls); p.setWidgetPropertyPane(DesignModuleFactory.getWidgetPropertyPane(fd)); p.setSureProperty(); } return p; } public static void registerNewFormActionClass(Class f) { instance.newFormAction = f; } public static Class getNewFormAction() { return instance.newFormAction; } public static void registerParaPropertyPaneClass(Class p) { instance.paraPropertyPane = p; } /** * 获取参数属性界面 * * @return 参数属性界面. */ public static Object getParaPropertyPane() { if (instance.paraPropertyPane != null) { try { return instance.paraPropertyPane.newInstance(); } catch (Exception e) { FRContext.getLogger().error("Error in Para PropertyPane"); } } return null; } public static void registerFormParaDesignerClass(Class f) { instance.formParaDesigner = f; } public static ParameterDesignerProvider getFormParaDesigner() { if (instance.formParaDesigner != null) { try { return (ParameterDesignerProvider) instance.formParaDesigner.newInstance(); } catch (Exception e) { FRContext.getLogger().error("error in form para designer"); } } return null; } public static void registerFormHierarchyPaneClass(Class fClass) { instance.formHierarchyPaneCls = fClass; } public static HierarchyTreePane getFormHierarchyPane() { return StableUtils.getInstance(instance.formHierarchyPaneCls); } public static void registerWidgetPropertyPaneClass(Class wp) { instance.widgetPropertyPane = wp; } public static BaseWidgetPropertyPane getWidgetPropertyPane(BaseFormDesigner fd) { BaseWidgetPropertyPane wp = null; if (instance.widgetPropertyPane != null) { wp = StableUtils.getInstance(instance.widgetPropertyPane); wp.setEditingFormDesigner(fd); wp.refreshDockingView(); } return wp; } public static MiddleChartComponent getChartComponent(BaseChartCollection collection) { MiddleChartComponent bcc = null; if (instance.chartComponentClass != null) { try { bcc = instance.chartComponentClass.newInstance(); bcc.populate(collection); } catch (InstantiationException e) { FRContext.getLogger().error("Error in ChartComponent instant", e); } catch (IllegalAccessException e) { FRContext.getLogger().error("Error in Access", e); } } return bcc; } /** * kunsnat: 初始化图表向导对话框, 调用静态方法showWindow, 参数window. * * @return 返回调出的ChartDailog */ public static MiddleChartDialog getChartDialog(Window window) { try { Constructor c; if (window instanceof Frame) { c = instance.chartDialogClass.getConstructor(Frame.class); } else { c = instance.chartDialogClass.getConstructor(Dialog.class); } return c.newInstance(window); } catch (Exception e) { FRContext.getLogger().error(e.getMessage(), e); } return null; } /** * kunsnat: 获取图表属性界面 * * @return 返回界面. */ public static BaseChartPropertyPane getChartPropertyPane() { BaseChartPropertyPane bp = null; if (instance.chartPropertyPaneClass != null) { bp = StableUtils.getInstance(instance.chartPropertyPaneClass); bp.setSureProperty(); } return bp; } public static void registerButtonDetailPaneClass(Class clazz) { instance.buttonDetailPaneClass = clazz; } public static Class getButtonDetailPaneClass() { return instance.buttonDetailPaneClass; } public static void registerParameterReader(ParameterReader reader) { if (instance.parameterReaderList == null) { instance.parameterReaderList = new ArrayList(); } instance.parameterReaderList.add(reader); } public static ParameterReader[] getParameterReaders() { if (instance.parameterReaderList == null) { return new ParameterReader[0]; } return instance.parameterReaderList.toArray(new ParameterReader[instance.parameterReaderList.size()]); } } \ No newline at end of file +package com.fr.design.module; import com.fr.base.FRContext; import com.fr.base.chart.BaseChartCollection; import com.fr.design.gui.chart.BaseChartPropertyPane; import com.fr.design.gui.chart.MiddleChartComponent; import com.fr.design.gui.chart.MiddleChartDialog; import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.core.WidgetOption; import com.fr.design.gui.frpane.BaseHyperlinkGroup; import com.fr.design.gui.frpane.HyperlinkGroupType; import com.fr.design.mainframe.BaseFormDesigner; import com.fr.design.mainframe.BaseWidgetPropertyPane; import com.fr.design.parameter.HierarchyTreePane; import com.fr.design.parameter.ParameterDesignerProvider; import com.fr.design.parameter.ParameterReader; import com.fr.form.ui.Widget; import com.fr.stable.StableUtils; import java.awt.*; import java.lang.reflect.Constructor; import java.util.ArrayList; /** * Created by IntelliJ IDEA. * Author : Richer * Version: 7.0.3 * Date: 13-7-8 * Time: 下午1:57 */ public class DesignModuleFactory { private static DesignModuleFactory instance = new DesignModuleFactory(); private DesignModuleFactory() { } private HyperlinkGroupType hyperlinkGroupType = new BaseHyperlinkGroup(); private NameableCreator[] creators4Hyperlink; private WidgetOption[] extraOptions; private Class chartEditorClass; private Class chartComponentClass; private Class chartDialogClass; private Class chartPropertyPaneClass; private Class newFormAction; private Class formParaDesigner; private Class paraPropertyPane; private Class formHierarchyPaneCls; private Class widgetPropertyPane; private Class buttonDetailPaneClass; private java.util.List parameterReaderList; public static void registerHyperlinkGroupType(HyperlinkGroupType hyperlinkGroupType) { instance.hyperlinkGroupType = hyperlinkGroupType; } public static HyperlinkGroupType getHyperlinkGroupType() { return instance.hyperlinkGroupType; } public static void registerCreators4Hyperlink(NameableCreator[] nameableCreators) { instance.creators4Hyperlink = nameableCreators; } public static NameableCreator[] getCreators4Hyperlink() { return instance.creators4Hyperlink; } public static void registerExtraWidgetOptions(WidgetOption[] options) { instance.extraOptions = options; } public static WidgetOption[] getExtraWidgetOptions() { if (instance.extraOptions == null) { instance.extraOptions = new WidgetOption[0]; } return instance.extraOptions; } public static void registerChartEditorClass(Class cls) { instance.chartEditorClass = cls; } public static Class getChartEditorClass() { return instance.chartEditorClass; } public static void registerChartComponentClass(Class bcc) { instance.chartComponentClass = bcc; } public static void registerChartDialogClass(Class cd) { instance.chartDialogClass = cd; } public static void registerChartPropertyPaneClass(Class p) { instance.chartPropertyPaneClass = p; } public static void registerNewFormActionClass(Class f) { instance.newFormAction = f; } public static Class getNewFormAction() { return instance.newFormAction; } public static void registerParaPropertyPaneClass(Class p) { instance.paraPropertyPane = p; } /** * 获取参数属性界面 * * @return 参数属性界面. */ public static Object getParaPropertyPane() { if (instance.paraPropertyPane != null) { try { return instance.paraPropertyPane.newInstance(); } catch (Exception e) { FRContext.getLogger().error("Error in Para PropertyPane"); } } return null; } public static void registerFormParaDesignerClass(Class f) { instance.formParaDesigner = f; } public static ParameterDesignerProvider getFormParaDesigner() { if (instance.formParaDesigner != null) { try { return (ParameterDesignerProvider) instance.formParaDesigner.newInstance(); } catch (Exception e) { FRContext.getLogger().error("error in form para designer"); } } return null; } public static void registerFormHierarchyPaneClass(Class fClass) { instance.formHierarchyPaneCls = fClass; } public static HierarchyTreePane getFormHierarchyPane() { return StableUtils.getInstance(instance.formHierarchyPaneCls); } public static void registerWidgetPropertyPaneClass(Class wp) { instance.widgetPropertyPane = wp; } public static BaseWidgetPropertyPane getWidgetPropertyPane(BaseFormDesigner fd) { BaseWidgetPropertyPane wp = null; if (instance.widgetPropertyPane != null) { wp = StableUtils.getInstance(instance.widgetPropertyPane); wp.setEditingFormDesigner(fd); wp.refreshDockingView(); } return wp; } public static MiddleChartComponent getChartComponent(BaseChartCollection collection) { MiddleChartComponent bcc = null; if (instance.chartComponentClass != null) { try { bcc = instance.chartComponentClass.newInstance(); bcc.populate(collection); } catch (InstantiationException e) { FRContext.getLogger().error("Error in ChartComponent instant", e); } catch (IllegalAccessException e) { FRContext.getLogger().error("Error in Access", e); } } return bcc; } /** * kunsnat: 初始化图表向导对话框, 调用静态方法showWindow, 参数window. * * @return 返回调出的ChartDailog */ public static MiddleChartDialog getChartDialog(Window window) { try { Constructor c; if (window instanceof Frame) { c = instance.chartDialogClass.getConstructor(Frame.class); } else { c = instance.chartDialogClass.getConstructor(Dialog.class); } return c.newInstance(window); } catch (Exception e) { FRContext.getLogger().error(e.getMessage(), e); } return null; } /** * kunsnat: 获取图表属性界面 * * @return 返回界面. */ public static BaseChartPropertyPane getChartPropertyPane() { BaseChartPropertyPane bp = null; if (instance.chartPropertyPaneClass != null) { bp = StableUtils.getInstance(instance.chartPropertyPaneClass); } return bp; } public static void clearChartPropertyPane() { if (instance.chartPropertyPaneClass != null) { StableUtils.clearInstance(instance.chartPropertyPaneClass); } } public static void registerButtonDetailPaneClass(Class clazz) { instance.buttonDetailPaneClass = clazz; } public static Class getButtonDetailPaneClass() { return instance.buttonDetailPaneClass; } public static void registerParameterReader(ParameterReader reader) { if (instance.parameterReaderList == null) { instance.parameterReaderList = new ArrayList(); } instance.parameterReaderList.add(reader); } public static ParameterReader[] getParameterReaders() { if (instance.parameterReaderList == null) { return new ParameterReader[0]; } return instance.parameterReaderList.toArray(new ParameterReader[instance.parameterReaderList.size()]); } } \ No newline at end of file diff --git a/designer_base/src/com/fr/design/selection/QuickEditor.java b/designer_base/src/com/fr/design/selection/QuickEditor.java index 9ca62f88db..1d46af9295 100644 --- a/designer_base/src/com/fr/design/selection/QuickEditor.java +++ b/designer_base/src/com/fr/design/selection/QuickEditor.java @@ -41,6 +41,14 @@ public abstract class QuickEditor extends JComponent protected abstract void refresh(); + + /** + * for 关闭时候释放 + */ + public void release () { + tc = null; + } + public static QuickEditor DEFAULT_EDITOR = new QuickEditor() { @Override diff --git a/designer_chart/src/com/fr/design/chart/gui/active/DataSeriesActiveGlyph.java b/designer_chart/src/com/fr/design/chart/gui/active/DataSeriesActiveGlyph.java index 0543764e31..ea3fab9772 100644 --- a/designer_chart/src/com/fr/design/chart/gui/active/DataSeriesActiveGlyph.java +++ b/designer_chart/src/com/fr/design/chart/gui/active/DataSeriesActiveGlyph.java @@ -6,8 +6,8 @@ import com.fr.base.chart.Glyph; import com.fr.chart.chartglyph.DataSeries; import com.fr.chart.chartglyph.PlotGlyph; import com.fr.design.chart.gui.ChartComponent; -import com.fr.design.mainframe.chart.ChartEditPane; import com.fr.design.mainframe.chart.PaneTitleConstants; +import com.fr.design.module.DesignModuleFactory; /** * Created by IntelliJ IDEA. @@ -35,8 +35,8 @@ public class DataSeriesActiveGlyph extends ActiveGlyph { if(chartComponent.getEditingChart() == null) { return; } - - ChartEditPane.getInstance().GoToPane(PaneTitleConstants.CHART_STYLE_TITLE, PaneTitleConstants.CHART_STYLE_SERIES_TITLE); + + DesignModuleFactory.getChartPropertyPane().getChartEditPane().gotoPane(PaneTitleConstants.CHART_STYLE_TITLE, PaneTitleConstants.CHART_STYLE_SERIES_TITLE); } @Override diff --git a/designer_chart/src/com/fr/design/chart/gui/active/action/SetAnalysisLineStyleAction.java b/designer_chart/src/com/fr/design/chart/gui/active/action/SetAnalysisLineStyleAction.java index b4ca9a1c8e..bac286c87e 100644 --- a/designer_chart/src/com/fr/design/chart/gui/active/action/SetAnalysisLineStyleAction.java +++ b/designer_chart/src/com/fr/design/chart/gui/active/action/SetAnalysisLineStyleAction.java @@ -3,8 +3,8 @@ package com.fr.design.chart.gui.active.action; import java.awt.event.ActionEvent; import com.fr.design.chart.gui.ChartComponent; -import com.fr.design.mainframe.chart.ChartEditPane; import com.fr.design.mainframe.chart.PaneTitleConstants; +import com.fr.design.module.DesignModuleFactory; import com.fr.general.Inter; public class SetAnalysisLineStyleAction extends ChartComponentAction{ @@ -20,7 +20,7 @@ public class SetAnalysisLineStyleAction extends ChartComponentAction{ } public void showAnalysisLineStylePane(){ - ChartEditPane.getInstance().GoToPane(PaneTitleConstants.CHART_STYLE_TITLE, PaneTitleConstants.CHART_STYLE_LINE_TITLE); + DesignModuleFactory.getChartPropertyPane().getChartEditPane().gotoPane(PaneTitleConstants.CHART_STYLE_TITLE, PaneTitleConstants.CHART_STYLE_LINE_TITLE); } diff --git a/designer_chart/src/com/fr/design/chart/gui/active/action/SetAxisStyleAction.java b/designer_chart/src/com/fr/design/chart/gui/active/action/SetAxisStyleAction.java index 26484bfb5c..60893c6fc2 100644 --- a/designer_chart/src/com/fr/design/chart/gui/active/action/SetAxisStyleAction.java +++ b/designer_chart/src/com/fr/design/chart/gui/active/action/SetAxisStyleAction.java @@ -3,8 +3,8 @@ package com.fr.design.chart.gui.active.action; import java.awt.event.ActionEvent; import com.fr.design.chart.gui.ChartComponent; -import com.fr.design.mainframe.chart.ChartEditPane; import com.fr.design.mainframe.chart.PaneTitleConstants; +import com.fr.design.module.DesignModuleFactory; import com.fr.general.Inter; import com.fr.stable.StringUtils; @@ -27,7 +27,7 @@ public class SetAxisStyleAction extends ChartComponentAction { public void showAxisStylePane() { String axisType = getActiveAxisGlyph() == null ? StringUtils.EMPTY : getActiveAxisGlyph().getAxisType(); - - ChartEditPane.getInstance().GoToPane(PaneTitleConstants.CHART_STYLE_TITLE, PaneTitleConstants.CHART_STYLE_AXIS_TITLE, axisType); + + DesignModuleFactory.getChartPropertyPane().getChartEditPane().gotoPane(PaneTitleConstants.CHART_STYLE_TITLE, PaneTitleConstants.CHART_STYLE_AXIS_TITLE, axisType); } } \ No newline at end of file diff --git a/designer_chart/src/com/fr/design/chart/gui/active/action/SetChartStyleAciton.java b/designer_chart/src/com/fr/design/chart/gui/active/action/SetChartStyleAciton.java index b3effe37aa..6d4ef617fd 100644 --- a/designer_chart/src/com/fr/design/chart/gui/active/action/SetChartStyleAciton.java +++ b/designer_chart/src/com/fr/design/chart/gui/active/action/SetChartStyleAciton.java @@ -3,8 +3,8 @@ package com.fr.design.chart.gui.active.action; import java.awt.event.ActionEvent; import com.fr.design.chart.gui.ChartComponent; -import com.fr.design.mainframe.chart.ChartEditPane; import com.fr.design.mainframe.chart.PaneTitleConstants; +import com.fr.design.module.DesignModuleFactory; import com.fr.general.Inter; /** @@ -26,6 +26,6 @@ public class SetChartStyleAciton extends ChartComponentAction { } public void showChartStylePane() { - ChartEditPane.getInstance().GoToPane(PaneTitleConstants.CHART_STYLE_TITLE, PaneTitleConstants.CHART_STYLE_AREA_TITLE, PaneTitleConstants.CHART_STYLE_AREA_AREA_TITLE); + DesignModuleFactory.getChartPropertyPane().getChartEditPane().gotoPane(PaneTitleConstants.CHART_STYLE_TITLE, PaneTitleConstants.CHART_STYLE_AREA_TITLE, PaneTitleConstants.CHART_STYLE_AREA_AREA_TITLE); } } \ No newline at end of file diff --git a/designer_chart/src/com/fr/design/chart/gui/active/action/SetDataLabelStyleAction.java b/designer_chart/src/com/fr/design/chart/gui/active/action/SetDataLabelStyleAction.java index e565d8e160..bce590ab25 100644 --- a/designer_chart/src/com/fr/design/chart/gui/active/action/SetDataLabelStyleAction.java +++ b/designer_chart/src/com/fr/design/chart/gui/active/action/SetDataLabelStyleAction.java @@ -3,8 +3,8 @@ package com.fr.design.chart.gui.active.action; import java.awt.event.ActionEvent; import com.fr.design.chart.gui.ChartComponent; -import com.fr.design.mainframe.chart.ChartEditPane; import com.fr.design.mainframe.chart.PaneTitleConstants; +import com.fr.design.module.DesignModuleFactory; import com.fr.general.Inter; public class SetDataLabelStyleAction extends ChartComponentAction{ @@ -20,7 +20,7 @@ public class SetDataLabelStyleAction extends ChartComponentAction{ } public void showDataLabelStylePane() { - ChartEditPane.getInstance().GoToPane(PaneTitleConstants.CHART_STYLE_TITLE, PaneTitleConstants.CHART_STYLE_LABEL_TITLE); + DesignModuleFactory.getChartPropertyPane().getChartEditPane().gotoPane(PaneTitleConstants.CHART_STYLE_TITLE, PaneTitleConstants.CHART_STYLE_LABEL_TITLE); } } \ No newline at end of file diff --git a/designer_chart/src/com/fr/design/chart/gui/active/action/SetDataSeriesAttrAction.java b/designer_chart/src/com/fr/design/chart/gui/active/action/SetDataSeriesAttrAction.java index 96480ebd8f..0ca8924d4e 100644 --- a/designer_chart/src/com/fr/design/chart/gui/active/action/SetDataSeriesAttrAction.java +++ b/designer_chart/src/com/fr/design/chart/gui/active/action/SetDataSeriesAttrAction.java @@ -3,8 +3,8 @@ package com.fr.design.chart.gui.active.action; import java.awt.event.ActionEvent; import com.fr.design.chart.gui.ChartComponent; -import com.fr.design.mainframe.chart.ChartEditPane; import com.fr.design.mainframe.chart.PaneTitleConstants; +import com.fr.design.module.DesignModuleFactory; import com.fr.general.Inter; /** @@ -21,6 +21,6 @@ public class SetDataSeriesAttrAction extends ChartComponentAction { } public void actionPerformed(ActionEvent e) { - ChartEditPane.getInstance().GoToPane(PaneTitleConstants.CHART_STYLE_TITLE, PaneTitleConstants.CHART_STYLE_SERIES_TITLE); + DesignModuleFactory.getChartPropertyPane().getChartEditPane().gotoPane(PaneTitleConstants.CHART_STYLE_TITLE, PaneTitleConstants.CHART_STYLE_SERIES_TITLE); } } \ No newline at end of file diff --git a/designer_chart/src/com/fr/design/chart/gui/active/action/SetDataSheetAction.java b/designer_chart/src/com/fr/design/chart/gui/active/action/SetDataSheetAction.java index 6aedd01b19..23258796db 100644 --- a/designer_chart/src/com/fr/design/chart/gui/active/action/SetDataSheetAction.java +++ b/designer_chart/src/com/fr/design/chart/gui/active/action/SetDataSheetAction.java @@ -3,8 +3,8 @@ package com.fr.design.chart.gui.active.action; import java.awt.event.ActionEvent; import com.fr.design.chart.gui.ChartComponent; -import com.fr.design.mainframe.chart.ChartEditPane; import com.fr.design.mainframe.chart.PaneTitleConstants; +import com.fr.design.module.DesignModuleFactory; import com.fr.general.Inter; /** @@ -28,6 +28,6 @@ public class SetDataSheetAction extends ChartComponentAction { } public void showDataSheetStylePane() { - ChartEditPane.getInstance().GoToPane(PaneTitleConstants.CHART_STYLE_TITLE, PaneTitleConstants.CHART_STYLE_DATA_TITLE); + DesignModuleFactory.getChartPropertyPane().getChartEditPane().gotoPane(PaneTitleConstants.CHART_STYLE_TITLE, PaneTitleConstants.CHART_STYLE_DATA_TITLE); } } \ No newline at end of file diff --git a/designer_chart/src/com/fr/design/chart/gui/active/action/SetLegendStyleAction.java b/designer_chart/src/com/fr/design/chart/gui/active/action/SetLegendStyleAction.java index 0a203db889..bc33e90fe3 100644 --- a/designer_chart/src/com/fr/design/chart/gui/active/action/SetLegendStyleAction.java +++ b/designer_chart/src/com/fr/design/chart/gui/active/action/SetLegendStyleAction.java @@ -3,8 +3,8 @@ package com.fr.design.chart.gui.active.action; import java.awt.event.ActionEvent; import com.fr.design.chart.gui.ChartComponent; -import com.fr.design.mainframe.chart.ChartEditPane; import com.fr.design.mainframe.chart.PaneTitleConstants; +import com.fr.design.module.DesignModuleFactory; import com.fr.general.Inter; /** @@ -27,6 +27,6 @@ public class SetLegendStyleAction extends ChartComponentAction { } public void showLegendStylePane() { - ChartEditPane.getInstance().GoToPane(PaneTitleConstants.CHART_STYLE_TITLE, PaneTitleConstants.CHART_STYLE_LEGNED_TITLE); + DesignModuleFactory.getChartPropertyPane().getChartEditPane().gotoPane(PaneTitleConstants.CHART_STYLE_TITLE, PaneTitleConstants.CHART_STYLE_LEGNED_TITLE); } } \ No newline at end of file diff --git a/designer_chart/src/com/fr/design/chart/gui/active/action/SetPlotStyleAction.java b/designer_chart/src/com/fr/design/chart/gui/active/action/SetPlotStyleAction.java index b49fb6ac65..686d8238c0 100644 --- a/designer_chart/src/com/fr/design/chart/gui/active/action/SetPlotStyleAction.java +++ b/designer_chart/src/com/fr/design/chart/gui/active/action/SetPlotStyleAction.java @@ -3,8 +3,8 @@ package com.fr.design.chart.gui.active.action; import java.awt.event.ActionEvent; import com.fr.design.chart.gui.ChartComponent; -import com.fr.design.mainframe.chart.ChartEditPane; import com.fr.design.mainframe.chart.PaneTitleConstants; +import com.fr.design.module.DesignModuleFactory; import com.fr.general.Inter; /** @@ -27,6 +27,6 @@ public class SetPlotStyleAction extends ChartComponentAction { } public void showPlotPane() { - ChartEditPane.getInstance().GoToPane(PaneTitleConstants.CHART_STYLE_TITLE, PaneTitleConstants.CHART_STYLE_AREA_TITLE, PaneTitleConstants.CHART_STYLE_AREA_PLOT_TITLE); + DesignModuleFactory.getChartPropertyPane().getChartEditPane().gotoPane(PaneTitleConstants.CHART_STYLE_TITLE, PaneTitleConstants.CHART_STYLE_AREA_TITLE, PaneTitleConstants.CHART_STYLE_AREA_PLOT_TITLE); } } \ No newline at end of file diff --git a/designer_chart/src/com/fr/design/chart/gui/active/action/SetTitleStyleAction.java b/designer_chart/src/com/fr/design/chart/gui/active/action/SetTitleStyleAction.java index f86f302a52..dc9a60575d 100644 --- a/designer_chart/src/com/fr/design/chart/gui/active/action/SetTitleStyleAction.java +++ b/designer_chart/src/com/fr/design/chart/gui/active/action/SetTitleStyleAction.java @@ -3,8 +3,8 @@ package com.fr.design.chart.gui.active.action; import java.awt.event.ActionEvent; import com.fr.design.chart.gui.ChartComponent; -import com.fr.design.mainframe.chart.ChartEditPane; import com.fr.design.mainframe.chart.PaneTitleConstants; +import com.fr.design.module.DesignModuleFactory; import com.fr.general.Inter; /** @@ -27,6 +27,6 @@ public class SetTitleStyleAction extends ChartComponentAction { } public void showTitlePane() { - ChartEditPane.getInstance().GoToPane(PaneTitleConstants.CHART_STYLE_TITLE, PaneTitleConstants.CHART_STYLE_TITLE_TITLE); + DesignModuleFactory.getChartPropertyPane().getChartEditPane().gotoPane(PaneTitleConstants.CHART_STYLE_TITLE, PaneTitleConstants.CHART_STYLE_TITLE_TITLE); } } \ No newline at end of file diff --git a/designer_chart/src/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperPoplinkPane.java b/designer_chart/src/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperPoplinkPane.java index fdcda38b2d..94836c7a38 100644 --- a/designer_chart/src/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperPoplinkPane.java +++ b/designer_chart/src/com/fr/design/chart/series/SeriesCondition/impl/ChartHyperPoplinkPane.java @@ -13,8 +13,8 @@ import com.fr.design.editor.ValueEditorPaneFactory; import com.fr.design.gui.itableeditorpane.ParameterTableModel; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.mainframe.chart.ChartEditPane; import com.fr.design.mainframe.chart.ChartHyperEditPane; +import com.fr.design.module.DesignModuleFactory; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.FRLogger; import com.fr.general.Inter; @@ -129,8 +129,8 @@ public class ChartHyperPoplinkPane extends BasicBeanPane { public void updateBean(ChartHyperPoplink chartHyperlink) { hyperEditPane.updateHyperLink(chartHyperlink); chartHyperlink.setChartCollection(chartComponent.update()); - - ChartEditPane.getInstance().fire();// 响应整个图表保存事件等. + + DesignModuleFactory.getChartPropertyPane().getChartEditPane().fire();// 响应整个图表保存事件等. if(itemNameTextField != null){ chartHyperlink.setItemName(this.itemNameTextField.getText()); } diff --git a/designer_chart/src/com/fr/design/mainframe/ChartAndWidgetPropertyPane.java b/designer_chart/src/com/fr/design/mainframe/ChartAndWidgetPropertyPane.java deleted file mode 100644 index f5547b7e62..0000000000 --- a/designer_chart/src/com/fr/design/mainframe/ChartAndWidgetPropertyPane.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright(c) 2001-2011, FineReport Inc, All Rights Reserved. - */ -package com.fr.design.mainframe; - -import java.awt.BorderLayout; -import java.awt.Component; - -import javax.swing.BorderFactory; -import javax.swing.JComponent; -import javax.swing.JPanel; -import javax.swing.SwingConstants; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; - -import com.fr.chart.chartattr.ChartCollection; -import com.fr.design.constants.UIConstants; -import com.fr.design.designer.TargetComponent; -import com.fr.design.gui.ibutton.UIToggleButton; -import com.fr.design.gui.ilable.UILabel; -import com.fr.design.gui.itabpane.TitleChangeListener; -import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.module.DesignModuleFactory; -import com.fr.general.Inter; - -public class ChartAndWidgetPropertyPane extends MiddleChartPropertyPane { - - public synchronized static ChartAndWidgetPropertyPane getInstance(BaseFormDesigner formEditor) { - if(singleton == null) { - singleton = new ChartAndWidgetPropertyPane(formEditor); - } - - singleton.setWidgetPropertyPane(DesignModuleFactory.getWidgetPropertyPane(formEditor)); - singleton.setSureProperty(); - return singleton; - } - - public static ChartAndWidgetPropertyPane getInstance() { - if(singleton == null) { - singleton = new ChartAndWidgetPropertyPane(); - } - return singleton; - } - - private static ChartAndWidgetPropertyPane singleton; - - private BaseWidgetPropertyPane widgetpane = null; - - private UIToggleButton hisButton; - - public ChartAndWidgetPropertyPane() { - - } - - public ChartAndWidgetPropertyPane(BaseFormDesigner formEditor) { - super(); - this.widgetpane = DesignModuleFactory.getWidgetPropertyPane(formEditor); - } - - public void setWidgetPropertyPane(BaseWidgetPropertyPane pane) { - this.widgetpane = pane; - } - - @Override - protected void createMainPane() { - this.add(chartEditPane, BorderLayout.CENTER); - } - - @Override - protected void createNameLabel() { - nameLabel = new UILabel(); - nameLabel.setHorizontalAlignment(SwingConstants.LEFT); - nameLabel.setBorder(BorderFactory.createEmptyBorder(-2, 6, 2, 0)); - } - - @Override - protected JComponent createNorthComponent() { - JPanel toolPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - - JPanel hisPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - hisPane.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); - hisButton = new UIToggleButton(Inter.getLocText(new String[]{"Widget", "Attribute"}), UIConstants.HISTORY_ICON); - hisButton.setNormalPainted(false); - hisButton.setBorderPaintedOnlyWhenPressed(true); - hisPane.add(hisButton, BorderLayout.CENTER); - - hisButton.addChangeListener(new ChangeListener() { - - @Override - public void stateChanged(ChangeEvent e) { - cardChange(); - } - }); - - toolPane.add(nameLabel, BorderLayout.CENTER); - toolPane.add(hisPane, BorderLayout.EAST); - - titleListener = new TitleChangeListener() { - - @Override - public void fireTitleChange(String addName) { - if(hisButton.isSelected()) { - nameLabel.setText(Inter.getLocText(new String[]{"Widget", "Form-Widget_Property_Table"})); - }else { - nameLabel.setText(Inter.getLocText("Chart-Property_Table") + '-' + addName); - } - } - }; - - return toolPane; - } - - /** - * 感觉ChartCollection加载图表属性界面. - * @param collection 收集图表 - * @param ePane 面板 - */ - public void populateChartPropertyPane(ChartCollection collection, TargetComponent ePane) { - super.populateChartPropertyPane(collection, ePane); - //表单中的图表切换界面上得更新 - resetChartEditPane(); - } - - protected void resetChartEditPane() { - cardChange(); - } - - private void cardChange() { - remove(chartEditPane); - remove((Component)widgetpane); - if(hisButton.isSelected()) { - nameLabel.setText(Inter.getLocText(new String[]{"Widget", "Form-Widget_Property_Table"})); - add((Component)widgetpane, BorderLayout.CENTER); - } else { - String tabname = chartEditPane.getSelectedTabName(); - nameLabel.setText(Inter.getLocText(new String[]{"Utils-The-Chart", "Form-Widget_Property_Table"}) + (tabname != null ? ('-' + chartEditPane.getSelectedTabName()) : "")); - add(chartEditPane, BorderLayout.CENTER); - } - validate(); - repaint(); - revalidate(); - } -} \ No newline at end of file diff --git a/designer_chart/src/com/fr/design/mainframe/ChartDesigner.java b/designer_chart/src/com/fr/design/mainframe/ChartDesigner.java index 715c02a324..f16fe98ec2 100644 --- a/designer_chart/src/com/fr/design/mainframe/ChartDesigner.java +++ b/designer_chart/src/com/fr/design/mainframe/ChartDesigner.java @@ -29,40 +29,13 @@ public class ChartDesigner extends TargetComponent implements MouseL private ChartArea chartArea;//上层区域 private boolean hasCalGap = false; - private ChartDesignerUI designerUI; private ArrayList changeListeners = new ArrayList(); - private ChartToolBarPane chartToolBarPane; - public ChartDesigner(ChartBook chartBook) { super(chartBook); this.addMouseListener(this); - designerUI = new ChartDesignerUI(); - chartToolBarPane = new ChartToolBarPane(this){ - public Dimension getPreferredSize() { - Dimension size = super.getPreferredSize(); - return new Dimension(size.width, ChartToolBarPane.TOTAL_HEIGHT); - } - }; - this.addMouseMotionListener(new MouseMotionAdapter() { - @Override - public void mouseMoved(MouseEvent e) { - if(designerUI!=null){ - designerUI.mouseMoved(e); - ChartDesigner.this.repaint(); - } - } - }); updateUI();// 初始化界面设计工具的UI实例 } - /** - * 设置其UI类为DesignerUI,负责渲染 - */ - @Override - public void updateUI() { - setUI(designerUI); - } - /** * 设置上层区域 * @param chartArea 图表区域 @@ -203,8 +176,6 @@ public class ChartDesigner extends TargetComponent implements MouseL * @param e 事件 */ public void mouseClicked(MouseEvent e) { - designerUI.mouseClicked(e); - this.chartToolBarPane.populate(); } /** @@ -247,18 +218,13 @@ public class ChartDesigner extends TargetComponent implements MouseL this.changeListeners.add(changeListener); } - public ChartToolBarPane getChartToolBarPane(){ - return this.chartToolBarPane; - } public void populate(){ - this.chartToolBarPane.populate(); } /** * 清除工具栏上面全局风格按钮的选中 */ public void clearToolBarStyleChoose(){ - chartToolBarPane.clearStyleChoose(); } } \ No newline at end of file diff --git a/designer_chart/src/com/fr/design/mainframe/ChartDesignerPropertyPane.java b/designer_chart/src/com/fr/design/mainframe/ChartDesignerPropertyPane.java deleted file mode 100644 index efa1eea628..0000000000 --- a/designer_chart/src/com/fr/design/mainframe/ChartDesignerPropertyPane.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (c) 2001-2014,FineReport Inc, All Rights Reserved. - */ - -package com.fr.design.mainframe; - -import com.fr.base.chart.BaseChartCollection; -import com.fr.chart.chartattr.ChartCollection; -import com.fr.design.designer.TargetComponent; -import com.fr.design.gui.chart.BaseChartPropertyPane; -import com.fr.design.gui.ilable.UILabel; -import com.fr.design.gui.itabpane.TitleChangeListener; -import com.fr.design.mainframe.chart.ChartDesignEditPane; -import com.fr.design.mainframe.chart.ChartEditPane; -import com.fr.general.Inter; - - -import javax.swing.*; -import java.awt.*; - -/** - * Created by IntelliJ IDEA. - * Author : daisy - * Version: 6.5.6 - * Date: 14-10-15 - * Time: 下午12:43 - */ -public class ChartDesignerPropertyPane extends BaseChartPropertyPane { - private static ChartDesignerPropertyPane instance; - private TargetComponentContainer container = new TargetComponentContainer(); - private ChartEditPane chartEditPane; - private UILabel nameLabel; - private TitleChangeListener titleListener = new TitleChangeListener() { - - @Override - public void fireTitleChange(String addName) { - nameLabel.setText(Inter.getLocText("Chart-Property_Table") + '-' + addName); - } - }; - - public synchronized static ChartDesignerPropertyPane getInstance() { - if (instance == null) { - instance = new ChartDesignerPropertyPane(); - } - instance.setSureProperty(); - return instance; - } - - public ChartDesignerPropertyPane() { - this.setLayout(new BorderLayout()); - this.setBorder(null); - - createNameLabel(); - this.add(nameLabel, BorderLayout.NORTH); - chartEditPane = ChartDesignEditPane.getInstance(); - this.add(chartEditPane, BorderLayout.CENTER); - } - - private void createNameLabel() { - nameLabel = new UILabel() { - @Override - public Dimension getPreferredSize() { - return new Dimension(super.getPreferredSize().width, 18); - } - }; - nameLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 1, 0)); - nameLabel.setHorizontalAlignment(SwingConstants.CENTER); - } - - @Override - public void setSureProperty() { - chartEditPane.setContainer(container); - chartEditPane.addTitleChangeListener(titleListener); - String tabname = chartEditPane.getSelectedTabName(); - nameLabel.setText(Inter.getLocText("Chart-Property_Table") + (tabname != null ? ('-' + chartEditPane.getSelectedTabName()) : "")); - resetChartEditPane(); - - } - - protected void resetChartEditPane() { - remove(chartEditPane); - add(chartEditPane, BorderLayout.CENTER); - validate(); - repaint(); - revalidate(); - } - - @Override - public void setSupportCellData(boolean supportCellData){ - - } - - /** - * 感觉ChartCollection加载图表属性界面. - * @param collection 收集图表 - * @param chartDesigner 图表设计 - */ - public void populateChartPropertyPane(BaseChartCollection collection, TargetComponent chartDesigner) { - if (collection instanceof ChartCollection) { - this.container.setEPane(chartDesigner); - chartEditPane.populate((ChartCollection) collection); - } - } - - @Override - public void setWidgetPropertyPane(BaseWidgetPropertyPane pane) { - - } - - /** - * 刷新 - */ - public void refreshDockingView() { - - } - - @Override - public String getViewTitle() { - return null; - } - - @Override - public Icon getViewIcon() { - return null; - } - - /** - * 位置 - * @return 位置 - */ - public Location preferredLocation() { - return null; - } -} \ No newline at end of file diff --git a/designer_chart/src/com/fr/design/mainframe/ChartPropertyPane.java b/designer_chart/src/com/fr/design/mainframe/ChartPropertyPane.java index d11279fed3..1c04543d68 100644 --- a/designer_chart/src/com/fr/design/mainframe/ChartPropertyPane.java +++ b/designer_chart/src/com/fr/design/mainframe/ChartPropertyPane.java @@ -17,15 +17,15 @@ public class ChartPropertyPane extends MiddleChartPropertyPane{ /** * 创建图表属性表实例. */ - public synchronized static ChartPropertyPane getInstance() { + private synchronized static ChartPropertyPane getInstance() { if(singleton == null) { singleton = new ChartPropertyPane(); } - + singleton.setSureProperty(); return singleton; } - + private static ChartPropertyPane singleton; @Override @@ -49,9 +49,8 @@ public class ChartPropertyPane extends MiddleChartPropertyPane{ protected JComponent createNorthComponent() { return nameLabel; } - - @Override - public void setWidgetPropertyPane(BaseWidgetPropertyPane pane) { - + + public synchronized static void clear() { + singleton = null; } } \ No newline at end of file diff --git a/designer_chart/src/com/fr/design/mainframe/ChartUndoState.java b/designer_chart/src/com/fr/design/mainframe/ChartUndoState.java deleted file mode 100644 index 04809b0dec..0000000000 --- a/designer_chart/src/com/fr/design/mainframe/ChartUndoState.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2001-2014,FineReport Inc, All Rights Reserved. - */ - -package com.fr.design.mainframe; - -import com.fr.form.ui.ChartBook; - -import java.awt.*; - -/** - * Created by IntelliJ IDEA. - * Author : daisy - * Version: 6.5.6 - * Date: 14-10-13 - * Time: 下午2:32 - */ -public class ChartUndoState extends BaseUndoState { - private ChartBook chartBook; - private Dimension designerSize; - private double widthValue; - private double heightValue; - - public ChartUndoState(JChart t,ChartArea area) { - super(t); - try { - this.chartBook = (ChartBook) t.getTarget().clone(); - } catch (CloneNotSupportedException e) { - throw new RuntimeException(e); - } - this.widthValue =area.getCustomWidth(); - this.heightValue = area.getCustomHeight(); - } - - - public ChartBook getChartBook(){ - return this.chartBook; - } - - /** - * 应用状态 - */ - public void applyState() { - this.getApplyTarget().applyUndoState(this); - - } -} \ No newline at end of file diff --git a/designer_chart/src/com/fr/design/mainframe/JChart.java b/designer_chart/src/com/fr/design/mainframe/JChart.java deleted file mode 100644 index 147c4d1b31..0000000000 --- a/designer_chart/src/com/fr/design/mainframe/JChart.java +++ /dev/null @@ -1,376 +0,0 @@ -/* - * Copyright (c) 2001-2014,FineReport Inc, All Rights Reserved. - * 图表类型文件 - */ - -package com.fr.design.mainframe; - -import com.fr.base.BaseUtils; -import com.fr.base.FRContext; -import com.fr.file.FILEChooserPane; -import com.fr.file.FILEChooserPane4Chart; -import com.fr.form.ui.ChartBook; -import com.fr.design.DesignModelAdapter; -import com.fr.design.event.TargetModifiedEvent; -import com.fr.design.event.TargetModifiedListener; -import com.fr.design.gui.imenu.UIMenuItem; -import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.mainframe.actions.ExcelExportAction4Chart; -import com.fr.design.mainframe.actions.PDFExportAction4Chart; -import com.fr.design.mainframe.actions.PNGExportAction4Chart; -import com.fr.design.mainframe.form.FormECCompositeProvider; -import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; -import com.fr.design.menu.ShortCut; -import com.fr.design.menu.ToolBarDef; -import com.fr.file.FILE; -import com.fr.general.Inter; -import com.fr.json.JSONArray; -import com.fr.json.JSONException; -import com.fr.json.JSONObject; -import com.fr.stable.StringUtils; - -import javax.swing.*; -import java.awt.*; -import java.awt.datatransfer.StringSelection; - -/** - * 图表crt文件 - *

- * Created by IntelliJ IDEA. - * Author : daisy - * Version: 6.5.6 - * Date: 14-10-13 - * Time: 下午2:28 - */ -public class JChart extends JTemplate { - public static final String XML_TAG = "JChart"; - private static final String CHART_CARD = "FORM"; - private static final String ELEMENTCASE_CARD = "ELEMENTCASE"; - - private static final String[] CARDNAME = new String[]{CHART_CARD, ELEMENTCASE_CARD}; - private static final int TOOLBARPANEDIMHEIGHT_FORM = 60; - //图表设计器 - ChartDesigner chartDesigner; - - //中间编辑区域, carllayout布局 - private JPanel tabCenterPane; - private CardLayout cardLayout; - //当前编辑的组件对象 - private JComponent editingComponent; - private FormECCompositeProvider reportComposite; - - public JChart() { - super(new ChartBook(), "Chart"); - } - - public JChart(ChartBook chartFile, FILE file) { - super(chartFile, file); - } - - @Override - protected JPanel createCenterPane() { - tabCenterPane = FRGUIPaneFactory.createCardLayout_S_Pane(); - JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); - centerPane.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 0, new Color(85, 85, 85))); - chartDesigner = new ChartDesigner(this.getTarget()); - ChartArea area = new ChartArea(chartDesigner); - centerPane.add(area, BorderLayout.CENTER); - tabCenterPane.add(centerPane, CHART_CARD, 0); - chartDesigner.addTargetModifiedListener(new TargetModifiedListener() { - public void targetModified(TargetModifiedEvent e) { - JChart.this.fireTargetModified();// 调用保存*, 调用刷新界面, 刷新工具栏按钮 - } - }); - - this.add(tabCenterPane, BorderLayout.CENTER); - return tabCenterPane; - } - - /** - * 移除选择 - */ - public void removeTemplateSelection() { - - } - - /** - * 刷新容器 - */ - public void refreshContainer() { - - } - - /** - * 移除参数面板选择 - */ - public void removeParameterPaneSelection() { - - } - - /** - * 创建设计模式 - * - * @return 返回模式 - */ - protected DesignModelAdapter createDesignModel() { - return null; - } - - /** - * 创建预览得菜单 - * - * @return 菜单 - */ - public UIMenuItem[] createMenuItem4Preview() { - return new UIMenuItem[0]; - } - - /** - * 创建撤销状态 - * - * @return 状态 - */ - protected ChartUndoState createUndoState() { - return new ChartUndoState(this,chartDesigner.getArea()); - } - - /** - * 应用撤销状态 - * - * @param chartUndoState 撤销状态 - */ - protected void applyUndoState(ChartUndoState chartUndoState) { - try { - this.setTarget((ChartBook)chartUndoState.getChartBook().clone()); - chartDesigner.setTarget(this.getTarget()); - chartDesigner.populate(); - }catch (CloneNotSupportedException e) { - throw new RuntimeException(e); - } - } - - /** - * 后缀 - * - * @return 后缀 - */ - public String suffix() { - return ".crt"; - } - - /** - * 复制 - */ - public void copy() { - - } - - /** - * 黏贴 - * - * @return 是否鸟贴成功 - */ - public boolean paste() { - return false; - } - - /** - * 是否剪切 - * - * @return 剪切成功 - */ - public boolean cut() { - return false; - } - - /** - * 创建权限编辑面板 - * - * @return 面板 - */ - public AuthorityEditPane createAuthorityEditPane() { - return null; - } - - /** - * 工具栏 - * - * @return 工具栏 - */ - public ToolBarMenuDockPlus getToolBarMenuDockPlus() { - return null; - } - - /** - * 东上面板 - * - * @return 面板 - */ - public JPanel getEastUpPane() { - return null; - } - - /** - * 东下面板 - * - * @return 面板 - */ - public JPanel getEastDownPane() { - return null; - } - - /** - * 工具栏菜单 - * - * @return 菜单 - */ - public ToolBarDef[] toolbars4Target() { - return new ToolBarDef[0]; - } - - /** - * 表单面板 - * - * @return 面板 - */ - public JPanel[] toolbarPanes4Form() { - return new JPanel[0]; - } - - /** - * 模版菜单 - * - * @return 模版菜单 - */ - public ShortCut[] shortcut4TemplateMenu() { - return new ShortCut[0]; - } - - /** - * 权限编辑菜单 - * - * @return 菜单 - */ - public ShortCut[] shortCuts4Authority() { - return new ShortCut[0]; - } - - /** - * 工具条表单 - * - * @return 表单 - */ - public JComponent[] toolBarButton4Form() { - return new JComponent[0]; - } - - /** - * 权限编辑工具栏,但是图表设计器里面用于正常工具栏不是全县编辑 - * - * @return 工具条 - */ - public JComponent toolBar4Authority() { - return chartDesigner.getChartToolBarPane(); - } - - /** - * 工具条高度 - * - * @return 工具条高度 - */ - public int getToolBarHeight() { - return 0; - } - - /** - * 是否是报表 - * - * @return 不是 - */ - public boolean isJWorkBook() { - return false; - } - - /** - * 是否是图表 - * - * @return 是则返回true - */ - public boolean isChartBook() { - return true; - } - - /** - * 设置权限编辑模式 - * - * @param isUpMode 没有权限编辑 - */ - public void setAuthorityMode(boolean isUpMode) { - - } - - /** - * 刷新工具区域 - */ - public void refreshToolArea() { - DesignerContext.getDesignerFrame().resetToolkitByPlus(JChart.this); - chartDesigner.populate(); - ChartDesignerPropertyPane.getInstance().populateChartPropertyPane(getTarget().getChartCollection(), chartDesigner); - EastRegionContainerPane.getInstance().replaceUpPane(ChartDesignerPropertyPane.getInstance()); - } - - /** - * 导出菜单的子菜单 ,目前用于图表设计器 - * - * @return 子菜单 - */ - public ShortCut[] shortcut4ExportMenu() { - return new ShortCut[]{new PNGExportAction4Chart(this), new ExcelExportAction4Chart(this), new PDFExportAction4Chart(this)}; - } - - public Icon getIcon() { - return BaseUtils.readIcon("/com/fr/design/images/chart.png"); - } - - public ChartDesigner getChartDesigner(){ - return chartDesigner; - } - - /** - * 复制JS代码 - */ - public void copyJS(){ - JSONObject jsonObject =this.getTarget().createExportConfig(); - String jsonString = StringUtils.EMPTY; - if(jsonObject != null){ - try{ - if(jsonObject.has("charts")){ - JSONArray charts = jsonObject.getJSONArray("charts"); - jsonString = charts.toString(2); - }else{ - jsonString = jsonObject.toString(2); - } - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("FR-Chart-CopyJS_Message"), Inter.getLocText("FR-Chart-Action_Copy")+"JS", JOptionPane.INFORMATION_MESSAGE); - }catch (JSONException ex){ - FRContext.getLogger().error(ex.getMessage()); - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("FR-Chart-CopyJS_Failed")+"!", Inter.getLocText("Error"), JOptionPane.ERROR_MESSAGE); - } - }else{ - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("FR-Chart-CopyJS_Failed")+"!", Inter.getLocText("Error"), JOptionPane.ERROR_MESSAGE); - } - StringSelection stringSelection = new StringSelection(jsonString); - Toolkit.getDefaultToolkit().getSystemClipboard().setContents(stringSelection, null); - }; - - /** - * 系列风格改动 - */ - public void styleChange(){ - chartDesigner.clearToolBarStyleChoose(); - } - - protected FILEChooserPane getFILEChooserPane(boolean isShowLoc){ - return new FILEChooserPane4Chart(true, isShowLoc); - } - -} \ No newline at end of file diff --git a/designer_chart/src/com/fr/design/mainframe/MiddleChartPropertyPane.java b/designer_chart/src/com/fr/design/mainframe/MiddleChartPropertyPane.java index 59cfb383e4..0b86c5a12f 100644 --- a/designer_chart/src/com/fr/design/mainframe/MiddleChartPropertyPane.java +++ b/designer_chart/src/com/fr/design/mainframe/MiddleChartPropertyPane.java @@ -13,11 +13,13 @@ import com.fr.base.chart.BaseChartCollection; import com.fr.chart.chartattr.ChartCollection; import com.fr.design.designer.TargetComponent; import com.fr.design.gui.chart.BaseChartPropertyPane; +import com.fr.design.gui.chart.ChartEditPaneProvider; import com.fr.design.gui.frpane.UITitlePanel; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itabpane.TitleChangeListener; import com.fr.design.mainframe.chart.ChartEditPane; import com.fr.general.Inter; +import com.fr.stable.StableUtils; public abstract class MiddleChartPropertyPane extends BaseChartPropertyPane{ @@ -37,7 +39,7 @@ public abstract class MiddleChartPropertyPane extends BaseChartPropertyPane{ createNameLabel(); this.add(createNorthComponent(), BorderLayout.NORTH); - chartEditPane = ChartEditPane.getInstance(); + chartEditPane = StableUtils.construct(ChartEditPane.class); chartEditPane.setSupportCellData(true); this.createMainPane(); } @@ -48,6 +50,12 @@ public abstract class MiddleChartPropertyPane extends BaseChartPropertyPane{ protected abstract void createMainPane(); + + @Override + public ChartEditPaneProvider getChartEditPane() { + return chartEditPane; + } + public void setSureProperty() { chartEditPane.setContainer(container); chartEditPane.addTitleChangeListener(titleListener); @@ -93,6 +101,12 @@ public abstract class MiddleChartPropertyPane extends BaseChartPropertyPane{ } } +// public void clear() { +// this.container.setEPane(null); +// chartEditPane.clear(); +// getParent().remove(this); +// } + /** * 返回View的标题. */ diff --git a/designer_chart/src/com/fr/design/mainframe/actions/AbstractExportAction4JChart.java b/designer_chart/src/com/fr/design/mainframe/actions/AbstractExportAction4JChart.java deleted file mode 100644 index 0601bd4f48..0000000000 --- a/designer_chart/src/com/fr/design/mainframe/actions/AbstractExportAction4JChart.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (c) 2001-2014,FineReport Inc, All Rights Reserved. - */ - -package com.fr.design.mainframe.actions; - -import com.fr.base.FRContext; -import com.fr.design.gui.iprogressbar.FRProgressBar; -import com.fr.form.ui.ChartBook; -import com.fr.design.mainframe.DesignerContext; -import com.fr.design.mainframe.DesignerFrame; -import com.fr.design.mainframe.JChart; -import com.fr.design.mainframe.exporter.Exporter4Chart; -import com.fr.file.FILE; -import com.fr.file.FILEChooserPane; -import com.fr.file.filter.ChooseFileFilter; -import com.fr.general.FRLogger; -import com.fr.general.Inter; - -import javax.swing.*; -import java.awt.event.ActionEvent; -import java.io.FileOutputStream; - -/** - * Created by IntelliJ IDEA. - * Author : daisy - * Version: 6.5.6 - * Date: 14-10-15 - * Time: 上午9:48 - */ -public abstract class AbstractExportAction4JChart extends JChartAction { - protected AbstractExportAction4JChart(JChart chart){ - super(chart); - } - - private FRProgressBar progressbar; - - protected ChartBook getChartBook(){ - return this.getEditingComponent().getTarget(); - } - - /** - * 执行方法 - * @param e 事件 - */ - public void actionPerformed(ActionEvent e) { - JChart chart = this.getEditingComponent(); - FILE editingFILE = chart.getEditingFILE(); - DesignerFrame designerFrame = DesignerContext.getDesignerFrame(); - - // 弹出参数 - final java.util.Map parameterMap = new java.util.HashMap(); - final ChartBook chartBook = getChartBook(); - - // Choose a file name.... - FILEChooserPane fileChooserPane = FILEChooserPane.getInstance(false, true); - fileChooserPane.setFILEFilter(this.getChooseFileFilter()); - - // 打开文件后输出文件名修改,eg:w.cpt.doc / w.svg.doc,去掉中间的后缀名~~ w.doc - String filenName = editingFILE.getName(); - if (filenName.indexOf('.') != -1) { - filenName = filenName.substring(0, editingFILE.getName().lastIndexOf('.')); - } - fileChooserPane.setFileNameTextField(filenName, "." + this.getDefaultExtension()); - int saveValue = fileChooserPane.showSaveDialog(designerFrame, "." + this.getDefaultExtension()); - if (saveValue == FILEChooserPane.CANCEL_OPTION || saveValue == FILEChooserPane.JOPTIONPANE_CANCEL_OPTION) { - fileChooserPane = null; - return; - } else if (saveValue == FILEChooserPane.JOPTIONPANE_OK_OPTION || saveValue == FILEChooserPane.OK_OPTION) { - FILE file = fileChooserPane.getSelectedFILE(); - try { - file.mkfile(); - } catch (Exception e1) { - FRLogger.getLogger().error("Error In Make New File"); - } - fileChooserPane = null; - FRContext.getLogger().info("\"" + file.getName() + "\"" + Inter.getLocText("Prepare_Export") + "!"); - - (progressbar = new FRProgressBar(createExportWork(file, chartBook), designerFrame, - Inter.getLocText("Exporting"), "", 0, 100)).start(); - } - - } - - private SwingWorker createExportWork(FILE file, final ChartBook chartBook) { - final String filePath = file.getPath(); - final String fileGetName = file.getName(); - - SwingWorker exportWorker = new SwingWorker() { - protected Void doInBackground() throws Exception { - Thread.sleep(100); //bug 10516 - try { - final FileOutputStream fileOutputStream = new FileOutputStream(filePath); - - this.setProgress(10); - dealExporter(fileOutputStream,chartBook); - this.setProgress(80); - fileOutputStream.close(); - this.setProgress(100); - - FRContext.getLogger().info("\"" + fileGetName + "\"" + Inter.getLocText("Finish_Export") + "!"); - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), - Inter.getLocText("Exported_successfully") + "\n" + filePath); - } catch (Exception exp) { - this.setProgress(100); - FRContext.getLogger().errorWithServerLevel(exp.getMessage(), exp); - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("Export_failed") + "\n" + filePath); - } - return null; - } - - public void done() { - progressbar.close(); - } - }; - return exportWorker; - } - - private void dealExporter(FileOutputStream fileOutputStream, final ChartBook chartBook) throws Exception { - final Exporter4Chart exporter = AbstractExportAction4JChart.this.getExporter(); - exporter.export(fileOutputStream,this.getEditingComponent()); - } - - - - protected abstract ChooseFileFilter getChooseFileFilter(); - - protected abstract String getDefaultExtension(); - - protected abstract Exporter4Chart getExporter(); - -} \ No newline at end of file diff --git a/designer_chart/src/com/fr/design/mainframe/actions/ExcelExportAction4Chart.java b/designer_chart/src/com/fr/design/mainframe/actions/ExcelExportAction4Chart.java deleted file mode 100644 index e1e64395a3..0000000000 --- a/designer_chart/src/com/fr/design/mainframe/actions/ExcelExportAction4Chart.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2001-2014,FineReport Inc, All Rights Reserved. - */ - -package com.fr.design.mainframe.actions; - -import com.fr.base.BaseUtils; -import com.fr.base.ExcelUtils; -import com.fr.design.mainframe.JChart; -import com.fr.design.mainframe.exporter.ExcelExporter4Chart; -import com.fr.design.mainframe.exporter.Exporter4Chart; -import com.fr.design.menu.MenuKeySet; -import com.fr.file.filter.ChooseFileFilter; -import com.fr.general.Inter; - -import javax.swing.*; -import java.awt.event.KeyEvent; - -/** - * Created by IntelliJ IDEA. - * Author : daisy - * Version: 6.5.6 - * Date: 14-10-15 - * Time: 上午9:52 - */ -public class ExcelExportAction4Chart extends AbstractExportAction4JChart { - - private MenuKeySet excel= new MenuKeySet() { - @Override - public char getMnemonic() { - return 'E'; - } - - @Override - public String getMenuName() { - return Inter.getLocText("FR-Chart-Format_Excel"); - } - - @Override - public KeyStroke getKeyStroke() { - return KeyStroke.getKeyStroke(KeyEvent.VK_E, KeyEvent.CTRL_MASK); - } - }; - - public ExcelExportAction4Chart(JChart chart) { - super(chart); - this.setMenuKeySet(excel); - this.setName(getMenuKeySet().getMenuKeySetName()); - this.setMnemonic(getMenuKeySet().getMnemonic()); - this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/excel.png")); - } - - - @Override - protected ChooseFileFilter getChooseFileFilter() { - return new ChooseFileFilter(new String[]{"xls", "xlsx"}, Inter.getLocText("Export-Excel")); - } - - @Override - protected String getDefaultExtension() { - return ExcelUtils.checkThirdJarSupportPOI() ? "xlsx" : "xls"; - } - - @Override - protected Exporter4Chart getExporter() { - return new ExcelExporter4Chart(); - } -} \ No newline at end of file diff --git a/designer_chart/src/com/fr/design/mainframe/actions/JChartAction.java b/designer_chart/src/com/fr/design/mainframe/actions/JChartAction.java deleted file mode 100644 index ba46678759..0000000000 --- a/designer_chart/src/com/fr/design/mainframe/actions/JChartAction.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2001-2014,FineReport Inc, All Rights Reserved. - */ - -package com.fr.design.mainframe.actions; - -import com.fr.design.actions.JTemplateAction; -import com.fr.design.mainframe.JChart; - -/** - * Created by IntelliJ IDEA. - * Author : daisy - * Version: 6.5.6 - * Date: 14-10-15 - * Time: 上午9:47 - */ -public abstract class JChartAction extends JTemplateAction { - public JChartAction(JChart jChart) { - super(jChart); - } -} \ No newline at end of file diff --git a/designer_chart/src/com/fr/design/mainframe/actions/NewChartAction.java b/designer_chart/src/com/fr/design/mainframe/actions/NewChartAction.java deleted file mode 100644 index bd62a689bd..0000000000 --- a/designer_chart/src/com/fr/design/mainframe/actions/NewChartAction.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2001-2014,FineReport Inc, All Rights Reserved. - */ - -package com.fr.design.mainframe.actions; - -import com.fr.base.BaseUtils; -import com.fr.design.actions.UpdateAction; -import com.fr.design.mainframe.DesignerContext; -import com.fr.design.mainframe.JChart; -import com.fr.design.menu.MenuKeySet; -import com.fr.general.Inter; - -import javax.swing.*; -import java.awt.event.ActionEvent; -import java.awt.event.InputEvent; -import java.awt.event.KeyEvent; - -/** - * Created by IntelliJ IDEA. - * Author : daisy - * Version: 6.5.6 - * Date: 14-10-13 - * Time: 下午3:22 - */ -public class NewChartAction extends UpdateAction{ - - public NewChartAction(){ - this.setMenuKeySet(NEW_CHART); - this.setName(getMenuKeySet().getMenuKeySetName()); - this.setMnemonic(getMenuKeySet().getMnemonic()); - this.setSmallIcon(BaseUtils.readIcon("com/fr/design/images/newchart_normal.png")); - this.setAccelerator(getMenuKeySet().getKeyStroke()); - } - - - /** - * 执行事件 - * @param e 事件 - */ - public void actionPerformed(ActionEvent e) { - DesignerContext.getDesignerFrame().addAndActivateJTemplate(new JChart()); - } - - public static final MenuKeySet NEW_CHART = new MenuKeySet() { - @Override - public char getMnemonic() { - return 'F'; - } - - @Override - public String getMenuName() { - return Inter.getLocText("M-New_ChartBook"); - } - - @Override - public KeyStroke getKeyStroke() { - return KeyStroke.getKeyStroke(KeyEvent.VK_F, InputEvent.CTRL_MASK); - } - }; -} \ No newline at end of file diff --git a/designer_chart/src/com/fr/design/mainframe/actions/PDFExportAction4Chart.java b/designer_chart/src/com/fr/design/mainframe/actions/PDFExportAction4Chart.java deleted file mode 100644 index df2f95598a..0000000000 --- a/designer_chart/src/com/fr/design/mainframe/actions/PDFExportAction4Chart.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2001-2014,FineReport Inc, All Rights Reserved. - */ - -package com.fr.design.mainframe.actions; - -import com.fr.base.BaseUtils; -import com.fr.design.mainframe.JChart; -import com.fr.design.mainframe.exporter.Exporter4Chart; -import com.fr.design.mainframe.exporter.PdfExporter4Chart; -import com.fr.design.menu.MenuKeySet; -import com.fr.file.filter.ChooseFileFilter; -import com.fr.general.Inter; - -import javax.swing.*; - -/** - * Created by IntelliJ IDEA. - * Author : daisy - * Version: 6.5.6 - * Date: 14-10-15 - * Time: 上午10:16 - */ -public class PDFExportAction4Chart extends AbstractExportAction4JChart { - - private MenuKeySet pdf = new MenuKeySet() { - @Override - public char getMnemonic() { - return 'P'; - } - - @Override - public String getMenuName() { - return Inter.getLocText("FR-Chart-Format_PDF"); - } - - @Override - public KeyStroke getKeyStroke() { - return null; - } - }; - - public PDFExportAction4Chart(JChart chart) { - super(chart); - this.setMenuKeySet(pdf); - this.setName(getMenuKeySet().getMenuKeySetName()); - this.setMnemonic(getMenuKeySet().getMnemonic()); - this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_file/pdf.png")); - } - - @Override - protected ChooseFileFilter getChooseFileFilter() { - return new ChooseFileFilter(new String[]{"pdf"}, Inter.getLocText("Export-PDF")); - } - - @Override - protected String getDefaultExtension() { - return "pdf"; - } - - @Override - protected Exporter4Chart getExporter() { - return new PdfExporter4Chart(); - } -} \ No newline at end of file diff --git a/designer_chart/src/com/fr/design/mainframe/actions/PNGExportAction4Chart.java b/designer_chart/src/com/fr/design/mainframe/actions/PNGExportAction4Chart.java deleted file mode 100644 index 2b04f80d4d..0000000000 --- a/designer_chart/src/com/fr/design/mainframe/actions/PNGExportAction4Chart.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2001-2014,FineReport Inc, All Rights Reserved. - */ - -package com.fr.design.mainframe.actions; - -import com.fr.base.BaseUtils; -import com.fr.design.mainframe.JChart; -import com.fr.design.mainframe.exporter.Exporter4Chart; -import com.fr.design.mainframe.exporter.ImageExporter4Chart; -import com.fr.design.menu.MenuKeySet; -import com.fr.file.filter.ChooseFileFilter; -import com.fr.general.Inter; - -import javax.swing.*; -import java.awt.event.KeyEvent; - -/** - * Created by IntelliJ IDEA. - * Author : daisy - * Version: 6.5.6 - * Date: 14-10-15 - * Time: 上午10:18 - */ -public class PNGExportAction4Chart extends AbstractExportAction4JChart { - - private MenuKeySet menuSet = new MenuKeySet() { - @Override - public char getMnemonic() { - return 'M'; - } - - @Override - public String getMenuName() { - return Inter.getLocText("FR-Chart-Format_Image"); - } - - @Override - public KeyStroke getKeyStroke() { - return KeyStroke.getKeyStroke(KeyEvent.VK_M, KeyEvent.CTRL_MASK); - } - }; - - public PNGExportAction4Chart(JChart chart) { - super(chart); - this.setMenuKeySet(menuSet); - this.setName(getMenuKeySet().getMenuKeySetName()); - this.setMnemonic(getMenuKeySet().getMnemonic()); - this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/exportimg.png")); - } - - @Override - protected ChooseFileFilter getChooseFileFilter() { - return new ChooseFileFilter(new String[]{"png"}, Inter.getLocText("Image")); - } - - @Override - protected String getDefaultExtension() { - return "png"; - } - - @Override - protected Exporter4Chart getExporter() { - return new ImageExporter4Chart(); - } -} \ No newline at end of file diff --git a/designer_chart/src/com/fr/design/mainframe/chart/AbstractChartAttrPane.java b/designer_chart/src/com/fr/design/mainframe/chart/AbstractChartAttrPane.java index 23f21463b3..8c4a21c814 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/AbstractChartAttrPane.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/AbstractChartAttrPane.java @@ -32,4 +32,5 @@ public abstract class AbstractChartAttrPane extends AbstractAttrNoScrollPane { public void refreshChartDataPane(ChartCollection collection){ } + } \ No newline at end of file diff --git a/designer_chart/src/com/fr/design/mainframe/chart/ChartEditPane.java b/designer_chart/src/com/fr/design/mainframe/chart/ChartEditPane.java index c3a2e1d502..f19c49d66f 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/ChartEditPane.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/ChartEditPane.java @@ -9,6 +9,7 @@ import com.fr.design.beans.FurtherBasicBeanPane; import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.tabledata.Prepare4DataSourceChange; import com.fr.design.dialog.BasicPane; +import com.fr.design.gui.chart.ChartEditPaneProvider; import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.gui.ibutton.UIHeadGroup; import com.fr.design.gui.itabpane.TitleChangeListener; @@ -30,20 +31,13 @@ import java.util.ArrayList; import java.util.Calendar; import java.util.List; -public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4DataSourceChange { - public synchronized static ChartEditPane getInstance() { - if (singleton == null) { - singleton = new ChartEditPane(); - } - return singleton; - } +public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4DataSourceChange, ChartEditPaneProvider { private final static int CHANGE_MIN_TIME = 80; protected ChartCollection collection; protected boolean isDefaultPane = true;//是否是默认的界面 - private static ChartEditPane singleton; protected List paneList; protected ChartTypePane typePane; @@ -79,10 +73,6 @@ public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4 registerDSChangeListener(); } - public static ChartEditPane getSingleton() { - return singleton; - } - //构建主面板 protected void createTabsPane() { Icon[] iconArray = new Icon[paneList.size()]; @@ -295,7 +285,7 @@ public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4 * * @param id 界面的标志.id */ - public void GoToPane(String... id) { + public void gotoPane(String... id) { this.setSelectedIndex(id); EastRegionContainerPane.getInstance().setWindow2PreferWidth(); } diff --git a/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartDataPane.java b/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartDataPane.java index d1a4088cd5..7c8589fb25 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartDataPane.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartDataPane.java @@ -105,4 +105,5 @@ public class ChartDataPane extends AbstractChartAttrPane { public void refreshChartDataPane(ChartCollection collection){ this.populate(collection); } + } \ No newline at end of file diff --git a/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java b/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java index f9c6e572c6..1c2bd85ed9 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java @@ -66,20 +66,20 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen return this.mouseOnChartTypeButtonPane; } - private AWTEventListener awt = new AWTEventListener() { - public void eventDispatched(AWTEvent event) { - //没有进行鼠标点击,则返回 - if (event instanceof MouseEvent && ((MouseEvent) event).getClickCount() > 0) { - if (currentEditingEditor != null && !ComparatorUtils.equals(event.getSource(), currentEditingEditor)) { - stopEditing(); - if (event.getSource() instanceof ChartChangeButton) { - ((ChartChangeButton) event.getSource()).mouseClick((MouseEvent) event); - } - populateBean(editingCollection); - } - } - } - }; +// private AWTEventListener awt = new AWTEventListener() { +// public void eventDispatched(AWTEvent event) { +// //没有进行鼠标点击,则返回 +// if (event instanceof MouseEvent && ((MouseEvent) event).getClickCount() > 0) { +// if (currentEditingEditor != null && !ComparatorUtils.equals(event.getSource(), currentEditingEditor)) { +// stopEditing(); +// if (event.getSource() instanceof ChartChangeButton) { +// ((ChartChangeButton) event.getSource()).mouseClick((MouseEvent) event); +// } +// populateBean(editingCollection); +// } +// } +// } +// }; public ChartTypeButtonPane(ChartTypePane chartTypePane){ this(); @@ -111,7 +111,7 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen initConfigButton(); initConfigCreator(); - Toolkit.getDefaultToolkit().addAWTEventListener(awt, AWTEvent.MOUSE_EVENT_MASK); + // Toolkit.getDefaultToolkit().addAWTEventListener(awt, AWTEvent.MOUSE_EVENT_MASK); } private void initConfigCreator() { @@ -328,7 +328,7 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen private void checkConfigButtonVisible() { addButton.setVisible(true); //新建一个collection - if(editingCollection.getState() == SwitchState.DEFAULT){ + if(editingCollection.getState() == SwitchState.DEFAULT && editingCollection.getSelectedChart() != null){ //Chart 不支持图表切换 configButton.setVisible(editingCollection.getSelectedChart().supportChange()); } diff --git a/designer_chart/src/com/fr/design/mainframe/chart/gui/data/DatabaseTableDataPane.java b/designer_chart/src/com/fr/design/mainframe/chart/gui/data/DatabaseTableDataPane.java index 4cb51f8f49..6c74211b8a 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/gui/data/DatabaseTableDataPane.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/gui/data/DatabaseTableDataPane.java @@ -102,4 +102,5 @@ public class DatabaseTableDataPane extends BasicPane{ } }); } + } \ No newline at end of file diff --git a/designer_chart/src/com/fr/design/mainframe/chart/gui/data/NormalChartDataPane.java b/designer_chart/src/com/fr/design/mainframe/chart/gui/data/NormalChartDataPane.java index bf64e4957a..d5aa2d93ec 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/gui/data/NormalChartDataPane.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/gui/data/NormalChartDataPane.java @@ -133,4 +133,5 @@ public class NormalChartDataPane extends DataContentsPane { public void setSupportCellData(boolean supportCellData) { dataPane.justSupportOneSelect(supportCellData); } + } \ No newline at end of file diff --git a/designer_chart/src/com/fr/design/mainframe/chart/gui/data/ReportDataPane.java b/designer_chart/src/com/fr/design/mainframe/chart/gui/data/ReportDataPane.java index cedc08a483..a3ede1b9f3 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/gui/data/ReportDataPane.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/gui/data/ReportDataPane.java @@ -52,7 +52,7 @@ public class ReportDataPane extends FurtherBasicBeanPane{ * 界面重置 */ public void reset() { - + clear(); } /** @@ -98,4 +98,8 @@ public class ReportDataPane extends FurtherBasicBeanPane{ public ChartCollection updateBean() { return null; } + + public void clear() { + this.removeAll(); + } } \ No newline at end of file diff --git a/designer_chart/src/com/fr/design/mainframe/chart/gui/other/ChartSwitchPane.java b/designer_chart/src/com/fr/design/mainframe/chart/gui/other/ChartSwitchPane.java index 6fdf74ce96..6b1b9d9985 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/gui/other/ChartSwitchPane.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/gui/other/ChartSwitchPane.java @@ -49,8 +49,8 @@ public class ChartSwitchPane extends AbstractAttrNoScrollPane{ if(currentChartEditPane != null) { currentChartEditPane.populate(editingChartCollection);// 选中新Plot之后 刷新对应界面, 比如超级链接等, 然后才能update. - currentChartEditPane.GoToPane(PaneTitleConstants.CHART_TYPE_TITLE); - currentChartEditPane.GoToPane(PaneTitleConstants.CHART_OTHER_TITLE, PaneTitleConstants.CHART_OTHER_TITLE_CHANGE); + currentChartEditPane.gotoPane(PaneTitleConstants.CHART_TYPE_TITLE); + currentChartEditPane.gotoPane(PaneTitleConstants.CHART_OTHER_TITLE, PaneTitleConstants.CHART_OTHER_TITLE_CHANGE); currentChartEditPane.fire(); } } diff --git a/designer_chart/src/com/fr/design/mainframe/exporter/ExcelExporter4Chart.java b/designer_chart/src/com/fr/design/mainframe/exporter/ExcelExporter4Chart.java deleted file mode 100644 index 71e02d1735..0000000000 --- a/designer_chart/src/com/fr/design/mainframe/exporter/ExcelExporter4Chart.java +++ /dev/null @@ -1,94 +0,0 @@ -package com.fr.design.mainframe.exporter; - -import com.fr.base.ExcelUtils; -import com.fr.design.mainframe.ChartDesigner; -import com.fr.design.mainframe.JChart; -import com.fr.general.FRLogger; -import com.fr.general.IOUtils; -import com.fr.stable.CoreGraphHelper; -import com.fr.third.v2.org.apache.poi.hssf.usermodel.HSSFClientAnchor; -import com.fr.third.v2.org.apache.poi.hssf.usermodel.HSSFWorkbook; -import com.fr.third.v2.org.apache.poi.ss.usermodel.ClientAnchor; -import com.fr.third.v2.org.apache.poi.ss.usermodel.Drawing; -import com.fr.third.v2.org.apache.poi.ss.usermodel.Sheet; -import com.fr.third.v2.org.apache.poi.ss.usermodel.Workbook; -import com.fr.third.v2.org.apache.poi.xssf.usermodel.XSSFClientAnchor; -import com.fr.third.v2.org.apache.poi.xssf.usermodel.XSSFWorkbook; -import java.awt.*; -import java.awt.image.BufferedImage; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.OutputStream; - -/** - * Created by IntelliJ IDEA. - * Author : daisy - * Version: 6.5.6 - * Date: 14-10-22 - * Time: 上午10:47 - */ -public class ExcelExporter4Chart extends ImageExporter4Chart { - private static final int PICTURE_TYPE_PNG = 6 ; - private static final int DEFAULT_COLUMN_SPAN = 12; - private static final int DEFAULT_ROW_SPAN = 26; - private Workbook workbook; - private ClientAnchor anchor; - - - - /** - * 导出 - * - * @param out 输出流 - * @param chart 图表文件 - * @throws Exception 异常 - */ - public void export(OutputStream out, JChart chart) throws Exception { - try { - ChartDesigner designer = chart.getChartDesigner(); - int imageWidth = designer.getArea().getCustomWidth(); - int imageHeight = designer.getArea().getCustomHeight(); - BufferedImage image = CoreGraphHelper.createBufferedImage(imageWidth, (int) imageHeight, BufferedImage.TYPE_INT_RGB); - Graphics2D g2d = image.createGraphics(); - paintGlyph(g2d,imageWidth,imageHeight,designer); - g2d.dispose(); - if (checkExcelExportVersion()) { - workbook = new XSSFWorkbook(); - }else{ - workbook = new HSSFWorkbook(); - } - Sheet sheet = workbook.createSheet(); - if(checkExcelExportVersion()){ - anchor = new XSSFClientAnchor(0,0,0,0,1,1,DEFAULT_COLUMN_SPAN,DEFAULT_ROW_SPAN); - }else{ - anchor = new HSSFClientAnchor(0,0,0,0,(short)1,1,(short)DEFAULT_COLUMN_SPAN,DEFAULT_ROW_SPAN); - } - Drawing patriarch = sheet.createDrawingPatriarch(); - patriarch.createPicture(anchor,loadPicture(image)); - workbook.write(out); - out.flush(); - }catch (Exception e){ - FRLogger.getLogger().error(e.getMessage()); - } - } - - private boolean checkExcelExportVersion() { - return ExcelUtils.checkThirdJarSupportPOI(); - } - // 加载图片. - private int loadPicture(BufferedImage bufferedImage)throws IOException { - ByteArrayOutputStream bos = null; - try { - bos = new ByteArrayOutputStream(); - IOUtils.writeImage(bufferedImage, "png", bos); - //引用这个参数是jdk1.5的版本 XSSFWorkbook.PICTURE_TYPE_PNG, 在1.4下无法编译, 所有手动去掉这个参数. - return workbook.addPicture(bos.toByteArray(), PICTURE_TYPE_PNG); - } finally { - if (bos != null) { - bos.flush(); - bos.close(); - } - bufferedImage.flush(); - } - } -} \ No newline at end of file diff --git a/designer_chart/src/com/fr/design/mainframe/exporter/Exporter4Chart.java b/designer_chart/src/com/fr/design/mainframe/exporter/Exporter4Chart.java deleted file mode 100644 index 3e4a36d127..0000000000 --- a/designer_chart/src/com/fr/design/mainframe/exporter/Exporter4Chart.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.fr.design.mainframe.exporter; -import com.fr.design.mainframe.JChart; - -import java.io.OutputStream; - -/** - * 图表设计器crt文件的导出成其他类型文件的接口 - * Created by IntelliJ IDEA. - * Author : daisy - * Version: 6.5.6 - * Date: 14-10-21 - * Time: 下午7:14 - */ -public interface Exporter4Chart { - - /** - * 将结果crt导出成目标文件 - * - * @param out 输出流 - * @param chart chart文件 - * @throws Exception 导出失败则抛出此异常 - */ - public void export(OutputStream out, JChart chart) throws Exception; - -} \ No newline at end of file diff --git a/designer_chart/src/com/fr/design/mainframe/exporter/ImageExporter4Chart.java b/designer_chart/src/com/fr/design/mainframe/exporter/ImageExporter4Chart.java deleted file mode 100644 index 4f3651d1fa..0000000000 --- a/designer_chart/src/com/fr/design/mainframe/exporter/ImageExporter4Chart.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2001-2014,FineReport Inc, All Rights Reserved. - */ - -package com.fr.design.mainframe.exporter; - -import com.fr.base.chart.BaseChartGlyph; -import com.fr.base.chart.chartdata.BaseTableDefinition; -import com.fr.base.chart.chartdata.ChartData; -import com.fr.base.chart.chartdata.TopDefinitionProvider; -import com.fr.chart.chartattr.Chart; -import com.fr.chart.chartattr.ChartCollection; -import com.fr.chart.chartglyph.ChartGlyph; -import com.fr.data.TableDataSource; -import com.fr.design.mainframe.ChartDesigner; -import com.fr.design.mainframe.JChart; -import com.fr.script.Calculator; -import com.fr.stable.Constants; -import com.fr.stable.CoreGraphHelper; - -import javax.imageio.ImageIO; -import java.awt.*; -import java.awt.image.BufferedImage; -import java.io.OutputStream; - -/** - * Created by IntelliJ IDEA. - * Author : daisy - * Version: 6.5.6 - * Date: 14-10-15 - * Time: 上午10:04 - */ -public class ImageExporter4Chart implements Exporter4Chart{ - private int resolution = Constants.DEFAULT_WEBWRITE_AND_SCREEN_RESOLUTION; - protected Calculator calculator; - - - public ImageExporter4Chart() { - - } - - /** - * 导出 - * - * @param out 输出流 - * @param chart 图表文件 - * @throws Exception 异常 - */ - public void export(OutputStream out, JChart chart) throws Exception { - ChartDesigner designer = chart.getChartDesigner(); - int imageWidth = designer.getArea().getCustomWidth(); - int imageHeight = designer.getArea().getCustomHeight(); - BufferedImage image = CoreGraphHelper.createBufferedImage(imageWidth, (int) imageHeight, BufferedImage.TYPE_INT_RGB); - Graphics2D g2d = image.createGraphics(); - paintGlyph(g2d,imageWidth,imageHeight,designer); - ImageIO.write(image, "png", out); - } - - protected void paintGlyph(Graphics2D g2d,int imageWidth,int imageHeight,ChartDesigner designer){ - if (imageWidth == 0 || imageHeight == 0) { - return; - } - this.calculator = Calculator.createCalculator(); - this.calculator.setAttribute(TableDataSource.class, null); - g2d.setColor(Color.white); - g2d.fillRect(0, 0, imageWidth,imageHeight); - ChartCollection chartCollection = (ChartCollection) designer.getTarget().getChartCollection(); - Chart editingChart = chartCollection.getSelectedChart(); - - TopDefinitionProvider topDefinition = editingChart.getFilterDefinition(); - ChartData chartData4Glyph = null; - if (topDefinition instanceof BaseTableDefinition) { - chartData4Glyph = ((BaseTableDefinition) topDefinition).calcu4ChartData(calculator, editingChart.getDataProcessor()); - } - - if (chartData4Glyph == null) { - chartData4Glyph = editingChart.defaultChartData(); - } - - BaseChartGlyph chartGlyph = null; - if (editingChart != null && editingChart.getPlot() != null) { - chartGlyph = editingChart.createGlyph(chartData4Glyph); - } - if (chartGlyph instanceof ChartGlyph) { - Image glyphImage = ((ChartGlyph) chartGlyph).toImage(imageWidth, imageHeight, resolution); - g2d.drawImage(glyphImage, 0, 0, null); - } - } -} \ No newline at end of file diff --git a/designer_chart/src/com/fr/design/mainframe/exporter/PdfExporter4Chart.java b/designer_chart/src/com/fr/design/mainframe/exporter/PdfExporter4Chart.java deleted file mode 100644 index b7a33e4d10..0000000000 --- a/designer_chart/src/com/fr/design/mainframe/exporter/PdfExporter4Chart.java +++ /dev/null @@ -1,382 +0,0 @@ -package com.fr.design.mainframe.exporter; - -import com.fr.base.FRContext; -import com.fr.design.mainframe.ChartDesigner; -import com.fr.design.mainframe.JChart; -import com.fr.general.ComparatorUtils; -import com.fr.general.FRLogger; -import com.fr.stable.OperatingSystem; -import com.fr.stable.StableUtils; -import com.fr.third.com.lowagie.text.Document; -import com.fr.third.com.lowagie.text.ExceptionConverter; -import com.fr.third.com.lowagie.text.Rectangle; -import com.fr.third.com.lowagie.text.pdf.*; - -import java.awt.*; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.IOException; -import java.io.OutputStream; -import java.util.HashMap; -import java.util.Locale; - -/** - * Created by IntelliJ IDEA. - * Author : daisy - * Version: 6.5.6 - * Date: 14-10-22 - * Time: 上午10:20 - */ -public class PdfExporter4Chart extends ImageExporter4Chart { - protected static MyFontMapper fontMapper = null; - - - /** - * 将结果crt导出成目标文件 - * - * @param out 输出流 - * @param chart chart文件 - * @throws Exception 导出失败则抛出此异常 - */ - public void export(OutputStream out, JChart chart) throws Exception { - ChartDesigner designer = chart.getChartDesigner(); - int imageWidth = designer.getArea().getCustomWidth(); - int imageHeight = designer.getArea().getCustomHeight(); - Document document = null; - PdfWriter writer = null; - ByteArrayOutputStream bo = new ByteArrayOutputStream(); - - if (document == null) { - document = new Document(new Rectangle(imageWidth, imageHeight)); - writer = PdfWriter.getInstance(document, bo); - document.open(); - } - //将chart画到PDF上去 - PdfContentByte cb = writer.getDirectContent(); - Graphics2D g2d = cb.createGraphics(imageWidth, imageHeight, prepareFontMapper()); - paintGlyph(g2d, imageWidth, imageHeight, designer); - g2d.dispose(); - if (document != null) { - document.close(); - } - - try { - out.write(bo.toByteArray()); - out.flush(); - out.close(); - } catch (IOException e) { - FRLogger.getLogger().error(e.getMessage()); - } - - - } - - private static void insertDirectory4Linux() { - /* - * alex:在222这台Redhat的机器上测试,发现把从windows拷来的simsun.ttc只有放在usr/share/fonts/default/Type1里面才可以用起来 - * 如果是放在usr/share/fonts目录或是${env}/resources/fonts目录下面,虽然可以读到,但是awtToPdf之后返回出去却依旧无法起作用 - * 中文字依然挤在一起 - * - * 觉得实在很诡异,可能必须放在系统字体的文件夹下面才行吧 - * - * PS:这是在用Graphics drawString的时候遇到的问题 - */ - //Linux - InsertDirectory(fontMapper, new File("/usr/X11R6/lib/X11/fonts")); - InsertDirectory(fontMapper, new File("/usr/share/fonts")); - String path = StableUtils.pathJoin(new String[]{FRContext.getCurrentEnv().getPath(), "fonts"}); - //再去web-inf/fonts里面找一下, 省去客户四处找jdk安装路径的麻烦 - InsertDirectory(fontMapper, new File(path)); - - //Solaris - InsertDirectory(fontMapper, new File("/usr/X/lib/X11/fonts/TrueType")); - InsertDirectory(fontMapper, new File("/usr/openwin/lib/X11/fonts/TrueType")); - } - - private static void insertDirectory4Windows() { - String libraryPath = System.getProperty("java.library.path"); - String[] libraryPathArray = StableUtils.splitString(libraryPath, ";"); - for (int i = 0; i < libraryPathArray.length; i++) { - File libraryFile = new File(libraryPathArray[i]); - InsertDirectory(fontMapper, new File(libraryFile, "Fonts")); - } - - InsertDirectory(fontMapper, new File("C:\\WINNT\\Fonts")); - InsertDirectory(fontMapper, new File("C:\\WINDOWS\\Fonts")); - } - - //peter:循环所有的目录,遍历所有的FontMapper. - protected static void InsertDirectory(MyFontMapper fontMapper, File dir) { - if (dir == null || !dir.exists() || !dir.isDirectory()) { - return; - } - - fontMapper.insertDirectory(dir.getAbsolutePath()); - - File[] listFiles = dir.listFiles(); - for (int i = 0; i < listFiles.length; i++) { - InsertDirectory(fontMapper, listFiles[i]); - } - } - - - /** - * Prepares FontMapper. - */ - protected static MyFontMapper prepareFontMapper() { - if (fontMapper != null) { - return fontMapper; - } - - fontMapper = new MyFontMapper(); - try { - //然后加载系统Font字体. - if (OperatingSystem.isWindows()) { - insertDirectory4Windows(); - - } else { - insertDirectory4Linux(); - - } - - String javaHomeProp = System.getProperty("java.home"); - if (javaHomeProp != null) { - File javaFontFile = new File(StableUtils.pathJoin(new String[]{ - javaHomeProp, "lib", "fonts" - })); - if (javaFontFile.exists() && javaFontFile.isDirectory()) { - InsertDirectory(fontMapper, javaFontFile); - } - } - - if (FRContext.getLocale() == Locale.CHINA || FRContext.getLocale() == Locale.CHINESE) { - MyFontMapper.defaultFont = BaseFont.createFont(MyFontMapper.CHINESE_SIMPLIFIED_FONT, MyFontMapper.CHINESE_SIMPLIFIED_ENCODING_H, BaseFont.NOT_EMBEDDED); - } else if (FRContext.getLocale() == Locale.TAIWAN || FRContext.getLocale() == Locale.TRADITIONAL_CHINESE) { - MyFontMapper.defaultFont = BaseFont.createFont(MyFontMapper.CHINESE_TRADITIONAL_FONT_M_SUNG, MyFontMapper.CHINESE_TRADITIONAL_ENCODING_H, BaseFont.NOT_EMBEDDED); - } else if (FRContext.getLocale() == Locale.JAPAN || FRContext.getLocale() == Locale.JAPANESE) { - MyFontMapper.defaultFont = BaseFont.createFont(MyFontMapper.JAPANESE_FONT_GO, MyFontMapper.JAPANESE_ENCODING_H, BaseFont.NOT_EMBEDDED); - } else if (FRContext.getLocale() == Locale.KOREA || FRContext.getLocale() == Locale.KOREAN) { - MyFontMapper.defaultFont = BaseFont.createFont(MyFontMapper.KOREAN_FONT_GO_THIC, MyFontMapper.KOREAN_ENCODING_H, BaseFont.NOT_EMBEDDED); - } else { - //默认也设置一个吧45422 , 不设置默认字体, linux英文环境导不出来 - MyFontMapper.defaultFont = BaseFont.createFont(MyFontMapper.CHINESE_SIMPLIFIED_FONT, MyFontMapper.CHINESE_SIMPLIFIED_ENCODING_H, BaseFont.NOT_EMBEDDED); - } - } catch (Exception e) { - FRContext.getLogger().error(e.getMessage(), e); - } - - return fontMapper; - } - - public static class MyFontMapper implements FontMapper { - - public static final String CHINESE_SIMPLIFIED_FONT = "STSong-Light"; - public static final String CHINESE_SIMPLIFIED_ENCODING_H = "UniGB-UCS2-H"; - public static final String CHINESE_SIMPLIFIED_ENCODING_V = "UniGB-UCS2-V"; - - public static final String CHINESE_TRADITIONAL_FONT_M_HEI = "MHei-Medium"; - public static final String CHINESE_TRADITIONAL_FONT_M_SUNG = "MSung-Light"; - public static final String CHINESE_TRADITIONAL_ENCODING_H = "UniCNS-UCS2-H"; - public static final String CHINESE_TRADITIONAL_ENCODING_V = "UniCNS-UCS2-V"; - - public static final String JAPANESE_FONT_GO = "HeiseiKakuGo-W5"; - public static final String JAPANESE_FONT_MIN = "HeiseiMin-W3"; - public static final String JAPANESE_ENCODING_H = "UniJIS-UCS2-H"; - public static final String JAPANESE_ENCODING_V = "UniJIS-UCS2-V"; - public static final String JAPANESE_ENCODING_HW_H = "UniJIS-UCS2-HW-H"; - public static final String JAPANESE_ENCODING_HW_V = "UniJIS-UCS2-HW-V"; - - public static final String KOREAN_FONT_GO_THIC = "HYGoThic-Medium"; - public static final String KOREAN_FONT_S_MYEONG_JO = "HYSMyeongJo-Medium"; - public static final String KOREAN_ENCODING_H = "UniKS-UCS2-H"; - public static final String KOREAN_ENCODING_V = "UniKS-UCS2-V"; - - public static BaseFont defaultFont; - private HashMap mapper; - - public static class BaseFontParameters { - - public String fontName; - public String encoding; - public boolean embedded; - public boolean cached; - public byte ttfAfm[]; - public byte pfb[]; - - public BaseFontParameters(String fontName) { - this.fontName = fontName; - encoding = BaseFont.IDENTITY_H; - embedded = true; - cached = true; - } - - /** - * toString方法 - * - * @return 对象说明 - */ - public String toString() { - return "{fontName:" + fontName + ",encoding:" + encoding + ",embedded:" + embedded + ",cached:" + cached; - } - } - - public MyFontMapper() { - mapper = new HashMap(); - } - - /** - * 转化字体 - * - * @param font awt字体 - * @return pdf字体 - */ - public BaseFont awtToPdf(Font font) { - try { - BaseFontParameters p = getBaseFontParameters(font.getFontName()); - - /* - * alex:不明真相 - * 经测试,Arial粗体在getFontName返回的是Arial Bold,可以在上面的方法中得到对应的p - * 所以getFontName是有用的 - * 但是在linux上测试,宋体在getFontName返回的却是Dialog这种逻辑字体,只有getName才返回SimSun - * 所以还需要getBaseFontParameters一下 - */ - if (p == null) { - p = getBaseFontParameters(font.getName()); - } - - if (p != null) { - return BaseFont.createFont(p.fontName, p.encoding, p.embedded, p.cached, p.ttfAfm, p.pfb); - } else { - // FRContext.getLogger().info(Inter.getLocText("Utils-Font_Not_Found") + ":" + font.getFontName()); - - // alex:未找到合适的字体,如果有默认字体,用之,没有的话,根据Bold & Italic设置字体 - if (defaultFont != null) { - return defaultFont; - } else { - String fontKey = BaseFont.COURIER; - if (font.isBold() && font.isItalic()) { - fontKey = BaseFont.COURIER_BOLDOBLIQUE; - } else if (font.isBold()) { - fontKey = BaseFont.COURIER_BOLD; - } else if (font.isItalic()) { - fontKey = BaseFont.COURIER_OBLIQUE; - } - - return BaseFont.createFont(fontKey, BaseFont.CP1252, BaseFont.NOT_EMBEDDED); - } - } - } catch (Exception e) { - FRContext.getLogger().error(e.getMessage(), e); - throw new ExceptionConverter(e); - } - } - - /** - * 转化字体 - * - * @param font pdf字体 - * @param size 大小 - * @return 转化后awt字体 - */ - public Font pdfToAwt(BaseFont font, int size) { - String[][] names = font.getFullFontName(); - if (names.length == 1) { - return new Font(names[0][3], 0, size); - } - String name10 = null; - String name3x = null; - for (int k = 0; k < names.length; ++k) { - String[] name = names[k]; - if (ComparatorUtils.equals(name[0], "1") && ComparatorUtils.equals(name[1], "0")) { - name10 = name[3]; - } else if (ComparatorUtils.equals(name[2], "1033")) { - name3x = name[3]; - break; - } - } - String finalName = name3x; - if (finalName == null) { - finalName = name10; - } - if (finalName == null) { - finalName = names[0][3]; - } - return new Font(finalName, 0, size); - } - - private BaseFontParameters getBaseFontParameters(String name) { - return (BaseFontParameters) mapper.get(name); - } - - protected void insertNames(String names[][], String path) { - String main = null; - int k = 0; - do { - if (k >= names.length) { - break; - } - String[] name = names[k]; - if (ComparatorUtils.equals(name[2], "1033")) { - main = name[3]; - break; - } - k++; - } while (true); - if (main == null) { - main = names[0][3]; - } - BaseFontParameters p = new BaseFontParameters(path); - - // alex:不一样的名字可能对应同样的BaseFontParameters,比如simsun和宋体都对应同样的p - mapper.put(main, p); - for (k = 0; k < names.length; k++) { - mapper.put(names[k][3], p); - } - } - - /** - * 插入目录里的字体 - * - * @param dir 目录 - * @return 插入数量 - */ - public int insertDirectory(String dir) { - File file = new File(dir); - if (!file.exists() || !file.isDirectory()) { - return 0; - } - - File[] files = file.listFiles(); - int count = 0; - for (int k = 0; k < files.length; k++) { - file = files[k]; - String name = file.getPath().toLowerCase(); - try { - if (matchPostfix(name)) { - String[][] names = BaseFont.getFullFontName(file.getPath(), BaseFont.CP1252, null); - insertNames(names, file.getPath()); - count++; - } else if (name.endsWith(".ttc")) { - String[] ttcs = BaseFont.enumerateTTCNames(file.getPath()); - for (int j = 0; j < ttcs.length; j++) { - String nt = String.valueOf(new StringBuffer(file.getPath()).append(',').append(j)); - String[][] names = BaseFont.getFullFontName(nt, BaseFont.CP1252, null); - insertNames(names, nt); - } - - count++; - } - } catch (Exception exception) { - FRContext.getLogger().error(exception.getMessage(), exception); - } - } - - return count; - } - - private boolean matchPostfix(String name) { - return name.endsWith(".ttf") || name.endsWith(".otf") || name.endsWith(".afm"); - } - } -} \ No newline at end of file diff --git a/designer_chart/src/com/fr/design/module/ChartDesignerModule.java b/designer_chart/src/com/fr/design/module/ChartDesignerModule.java index d86c469ff0..38034efd04 100644 --- a/designer_chart/src/com/fr/design/module/ChartDesignerModule.java +++ b/designer_chart/src/com/fr/design/module/ChartDesignerModule.java @@ -1 +1 @@ -package com.fr.design.module; import com.fr.chart.base.ChartInternationalNameContentBean; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.charttypes.ChartTypeManager; import com.fr.design.ChartTypeInterfaceManager; import com.fr.design.actions.core.ActionFactory; import com.fr.design.chart.ChartDialog; import com.fr.design.chart.gui.ChartComponent; import com.fr.design.chart.gui.ChartWidgetOption; import com.fr.design.gui.core.WidgetOption; import com.fr.design.mainframe.App; import com.fr.design.mainframe.ChartAndWidgetPropertyPane; import com.fr.design.mainframe.ChartPropertyPane; import com.fr.form.ui.ChartEditor; import com.fr.general.IOUtils; import com.fr.general.Inter; import com.fr.stable.bridge.StableFactory; import com.fr.stable.plugin.ExtraChartDesignClassManagerProvider; import javax.swing.*; /** * Created by IntelliJ IDEA. * Author : Richer * Version: 7.0.3 * Date: 13-7-8 * Time: 上午9:13 */ public class ChartDesignerModule extends DesignModule { public void start() { super.start(); dealBeforeRegister(); register(); registerFloatEditor(); } protected void dealBeforeRegister(){ StableFactory.registerMarkedClass(ExtraChartDesignClassManagerProvider.XML_TAG, ChartTypeInterfaceManager.class); StableFactory.getStaticMarkedInstanceObjectFromClass(ExtraChartDesignClassManagerProvider.XML_TAG, ExtraChartDesignClassManagerProvider.class); } private void register(){ DesignModuleFactory.registerHyperlinkGroupType(new ChartHyperlinkGroup()); DesignModuleFactory.registerChartEditorClass(ChartEditor.class); DesignModuleFactory.registerChartComponentClass(ChartComponent.class); DesignModuleFactory.registerChartDialogClass(ChartDialog.class); DesignModuleFactory.registerChartAndWidgetPropertyPane(ChartAndWidgetPropertyPane.class); DesignModuleFactory.registerChartPropertyPaneClass(ChartPropertyPane.class); ActionFactory.registerChartPreStyleAction(new ChartPreStyleAction()); } protected void registerFloatEditor() { ActionFactory.registerChartCollection(ChartCollection.class); } /** * 返回设计器能打开的模板类型的一个数组列表 * * @return 可以打开的模板类型的数组 */ public App[] apps4TemplateOpener() { return new App[0]; } protected WidgetOption[] options4Show() { ChartInternationalNameContentBean[] typeName = ChartTypeManager.getInstance().getAllChartBaseNames(); ChartWidgetOption[] child = new ChartWidgetOption[typeName.length]; for (int i = 0; i < typeName.length; i++) { String plotID = typeName[i].getPlotID(); Chart[] rowChart = ChartTypeManager.getInstance().getChartTypes(plotID); if(rowChart == null) { continue; } String iconPath = ChartTypeInterfaceManager.getInstance().getIconPath(plotID); Icon icon = IOUtils.readIcon(iconPath); child[i] = new ChartWidgetOption(Inter.getLocText(typeName[i].getName()), icon, ChartEditor.class, rowChart[0]); } return child; } public String getInterNationalName() { return Inter.getLocText("FR-Chart-Design_ChartModule"); } } \ No newline at end of file +package com.fr.design.module; import com.fr.chart.base.ChartInternationalNameContentBean; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.charttypes.ChartTypeManager; import com.fr.design.ChartTypeInterfaceManager; import com.fr.design.actions.core.ActionFactory; import com.fr.design.chart.ChartDialog; import com.fr.design.chart.gui.ChartComponent; import com.fr.design.chart.gui.ChartWidgetOption; import com.fr.design.gui.core.WidgetOption; import com.fr.design.mainframe.App; import com.fr.design.mainframe.ChartPropertyPane; import com.fr.form.ui.ChartEditor; import com.fr.general.IOUtils; import com.fr.general.Inter; import com.fr.stable.bridge.StableFactory; import com.fr.stable.plugin.ExtraChartDesignClassManagerProvider; import javax.swing.*; /** * Created by IntelliJ IDEA. * Author : Richer * Version: 7.0.3 * Date: 13-7-8 * Time: 上午9:13 */ public class ChartDesignerModule extends DesignModule { public void start() { super.start(); dealBeforeRegister(); register(); registerFloatEditor(); } protected void dealBeforeRegister(){ StableFactory.registerMarkedClass(ExtraChartDesignClassManagerProvider.XML_TAG, ChartTypeInterfaceManager.class); StableFactory.getStaticMarkedInstanceObjectFromClass(ExtraChartDesignClassManagerProvider.XML_TAG, ExtraChartDesignClassManagerProvider.class); } private void register(){ DesignModuleFactory.registerHyperlinkGroupType(new ChartHyperlinkGroup()); DesignModuleFactory.registerChartEditorClass(ChartEditor.class); DesignModuleFactory.registerChartComponentClass(ChartComponent.class); DesignModuleFactory.registerChartDialogClass(ChartDialog.class); DesignModuleFactory.registerChartPropertyPaneClass(ChartPropertyPane.class); ActionFactory.registerChartPreStyleAction(new ChartPreStyleAction()); } protected void registerFloatEditor() { ActionFactory.registerChartCollection(ChartCollection.class); } /** * 返回设计器能打开的模板类型的一个数组列表 * * @return 可以打开的模板类型的数组 */ public App[] apps4TemplateOpener() { return new App[0]; } protected WidgetOption[] options4Show() { ChartInternationalNameContentBean[] typeName = ChartTypeManager.getInstance().getAllChartBaseNames(); ChartWidgetOption[] child = new ChartWidgetOption[typeName.length]; for (int i = 0; i < typeName.length; i++) { String plotID = typeName[i].getPlotID(); Chart[] rowChart = ChartTypeManager.getInstance().getChartTypes(plotID); if(rowChart == null) { continue; } String iconPath = ChartTypeInterfaceManager.getInstance().getIconPath(plotID); Icon icon = IOUtils.readIcon(iconPath); child[i] = new ChartWidgetOption(Inter.getLocText(typeName[i].getName()), icon, ChartEditor.class, rowChart[0]); } return child; } public String getInterNationalName() { return Inter.getLocText("FR-Chart-Design_ChartModule"); } } \ No newline at end of file diff --git a/designer_chart/src/com/fr/design/module/ChartStartModule.java b/designer_chart/src/com/fr/design/module/ChartStartModule.java deleted file mode 100644 index 0dab6e9235..0000000000 --- a/designer_chart/src/com/fr/design/module/ChartStartModule.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) 2001-2014,FineReport Inc, All Rights Reserved. - */ - -package com.fr.design.module; - -import com.fr.base.BaseUtils; -import com.fr.base.FRContext; -import com.fr.base.io.XMLEncryptUtils; -import com.fr.chart.base.ChartInternationalNameContentBean; -import com.fr.chart.chartattr.Chart; -import com.fr.chart.charttypes.ChartTypeManager; -import com.fr.chart.module.ChartModule; -import com.fr.design.DesignerEnvManager; -import com.fr.design.chart.gui.ChartWidgetOption; -import com.fr.design.gui.core.WidgetOption; -import com.fr.design.mainframe.*; -import com.fr.file.FILE; -import com.fr.form.ui.ChartBook; -import com.fr.form.ui.ChartEditor; -import com.fr.general.Inter; -import com.fr.general.ModuleContext; - -/** - * Created by IntelliJ IDEA. - * Author : daisy - * Version: 6.5.6 - * Date: 14-10-13 - * Time: 下午2:56 - */ -public class ChartStartModule extends ChartDesignerModule { - - protected void dealBeforeRegister(){ - ModuleContext.startModule(ChartModule.class.getName()); - } - - protected void registerFloatEditor() { - - } - - protected WidgetOption[] options4Show() { - ChartInternationalNameContentBean[] typeName = ChartTypeManager.getInstance().getAllChartBaseNames(); - ChartWidgetOption[] child = new ChartWidgetOption[typeName.length]; - for (int i = 0; i < typeName.length; i++) { - Chart[] rowChart = ChartTypeManager.getInstance().getChartTypes(typeName[i].getPlotID()); - child[i] = new ChartWidgetOption(Inter.getLocText(typeName[i].getName()), BaseUtils - .readIcon("com/fr/design/images/form/toolbar/" + typeName[i].getName() + ".png"), - ChartEditor.class, rowChart[0]); - } - return child; - } - - /** - * 应用打开器 - * @return 应用 - */ - public App[] apps4TemplateOpener() { - return new App[]{new AbstractAppProvider() { - - @Override - public String[] defaultExtentions() { - return new String[]{"crt"}; - } - - @Override - public JTemplate openTemplate(FILE tplFile) { - return new JChart(asIOFile(tplFile), tplFile); - } - - @Override - public ChartBook asIOFile(FILE file) { - if (XMLEncryptUtils.isCptEncoded() && - !XMLEncryptUtils.checkVaild(DesignerEnvManager.getEnvManager().getEncryptionKey())) { - if (!new DecodeDialog(file).isPwdRight()) { - FRContext.getLogger().error(Inter.getLocText("FR-Chart-Password_Error")); - return new ChartBook(); - } - } - - - ChartBook tpl = new ChartBook(); - //打开通知 - FRContext.getLogger().info(Inter.getLocText(new String[]{"LOG-Is_Being_Openned", "LOG-Please_Wait"}, - new String[]{"\"" + file.getName() + "\"" + ",", "..."})); - try { - tpl.readStream(file.asInputStream()); - } catch (Exception exp) { - FRContext.getLogger().error("Failed to generate frm from " + file, exp); - return null; - } - return tpl; - } - }}; - } -} \ No newline at end of file diff --git a/designer_chart/src/com/fr/start/ChartSplashPane.java b/designer_chart/src/com/fr/start/ChartSplashPane.java deleted file mode 100644 index d081d21642..0000000000 --- a/designer_chart/src/com/fr/start/ChartSplashPane.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.fr.start; - -import java.awt.Image; - -import com.fr.base.BaseUtils; - -public class ChartSplashPane extends SplashPane{ - - /** - * 创建启动画面的背景图片 - * - * @return 背景图片 - * - */ - public Image createSplashBackground() { - return BaseUtils.readImage("/com/fr/design/images/splash4Chart.png"); - } -} \ No newline at end of file diff --git a/designer_chart/src/com/fr/start/Designer4Chart.java b/designer_chart/src/com/fr/start/Designer4Chart.java deleted file mode 100644 index 83de32da70..0000000000 --- a/designer_chart/src/com/fr/start/Designer4Chart.java +++ /dev/null @@ -1,406 +0,0 @@ -/* - * Copyright (c) 2001-2014,FineReport Inc, All Rights Reserved. - */ - -package com.fr.start; - -import com.fr.base.BaseUtils; -import com.fr.base.FRContext; -import com.fr.design.DesignerEnvManager; -import com.fr.design.actions.file.WebPreviewUtils; -import com.fr.design.actions.help.AboutAction; -import com.fr.design.constants.UIConstants; -import com.fr.design.file.HistoryTemplateListPane; -import com.fr.design.file.MutilTempalteTabPane; -import com.fr.design.file.NewTemplatePane; -import com.fr.design.gui.ibutton.UIButton; -import com.fr.design.gui.itoolbar.UILargeToolbar; -import com.fr.design.mainframe.*; -import com.fr.design.mainframe.actions.*; -import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus; -import com.fr.design.menu.*; -import com.fr.design.module.ChartStartModule; -import com.fr.general.FRFont; -import com.fr.general.Inter; -import com.fr.general.web.ParameterConsts; -import com.fr.stable.Constants; - -import javax.swing.*; -import javax.swing.border.MatteBorder; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.InputEvent; -import java.awt.event.KeyEvent; -import java.util.ArrayList; - -/** - * Created by IntelliJ IDEA. - * Author : daisy - * Version: 6.5.6 - * Date: 14-10-13 - * Time: 上午11:02 - */ -public class Designer4Chart extends BaseDesigner { - private static final int TOOLBAR_HEIGHT = 53; - private static final int TOOLBAR_WIDTH =60+34+7+1+7 ; - private static final int GAP = 7; - private static final int EAST_WIDTH = 292; - private static final int MESSAGEPORT = 51460; - private UIButton saveButton; - private UIButton undo; - private UIButton redo; - private UIButton run; - private UIButton copy; - - /** - * 主函数 - * - * @param args 入口参数 - */ - public static void main(String[] args) { - new Designer4Chart(args); - } - - public Designer4Chart(String[] args) { - super(args); - } - - @Override - protected String module2Start() { - EastRegionContainerPane.getInstance().setDownPaneVisible(false); - EastRegionContainerPane.getInstance().setContainerWidth(EAST_WIDTH); - return ChartStartModule.class.getName(); - } - - protected void initLanguage() { - //这两句的位置不能随便调换,因为会影响语言切换的问题 - FRContext.setLanguage(Constants.LANGUAGE_ENGLISH); - } - - protected void initDefaultFont(){ - FRContext.getDefaultValues().setFRFont(FRFont.getInstance("Meiryo", Font.PLAIN, 9)); - } - - /** - * build得路径 - * @return build得路径 - */ - public String buildPropertiesPath() { - return "/com/fr/chart/base/build.properties"; - } - - /** - * 创建文件菜单项 - * @return 菜单项 - */ - public ShortCut[] createNewFileShortCuts() { - ArrayList shortCuts = new ArrayList(); - shortCuts.add(new NewChartAction()); - return shortCuts.toArray(new ShortCut[shortCuts.size()]); - } - - /** - * 创建新模版 - * @return 模版 - */ - public JTemplate createNewTemplate() { - return new JChart(); - } - - protected void resetToolTips(){ - copy.setToolTipText(Inter.getLocText("FR-Chart-Action_Copy")+"JS"); - run.setToolTipText(PREVIEW.getMenuKeySetName()); - } - - /** - * 创建设计器上几个比较大的图标:新建cpt,保存,前进,后退,运行。 - * - * @return 返回大图标对应的工具栏 - */ - public UILargeToolbar createLargeToolbar() { - - UILargeToolbar largeToolbar = new UILargeToolbar(FlowLayout.LEFT){ - public Dimension getPreferredSize() { - return new Dimension(TOOLBAR_WIDTH ,TOOLBAR_HEIGHT); - } - }; - largeToolbar.setLayout(new FlowLayout(FlowLayout.CENTER, 0, 4)); - largeToolbar.add(new JPanel() { - public Dimension getPreferredSize() { - Dimension dim = super.getPreferredSize(); - dim.width = 1; - return dim; - } - }); - createRunButton(); - largeToolbar.add(run); - largeToolbar.add(new JPanel() { - public Dimension getPreferredSize() { - Dimension dim = super.getPreferredSize(); - dim.width = GAP; - return dim; - } - }); - largeToolbar.addSeparator(new Dimension(2, 42)); - largeToolbar.add(new JPanel() { - public Dimension getPreferredSize() { - Dimension dim = super.getPreferredSize(); - dim.width = GAP; - return dim; - } - }); - createCopyButton(); - largeToolbar.add(copy); - largeToolbar.add(new JPanel() { - public Dimension getPreferredSize() { - Dimension dim = super.getPreferredSize(); - dim.width = GAP; - return dim; - } - }); - largeToolbar.addSeparator(new Dimension(2, 42)); - - largeToolbar.setBorder(new MatteBorder(new Insets(0, 0, 1, 0), UIConstants.LINE_COLOR)); - return largeToolbar; - } - - protected int getStartPort(){ - return MESSAGEPORT; - } - - protected DesignerFrame createDesignerFrame(){ - - return new DesignerFrame4Chart(this); - } - - /** - * 创建上面一排的工具栏按钮 - * - * @return 按钮 - */ - public UIButton[] createUp() { - return new UIButton[]{createSaveButton(), createUndoButton(), createRedoButton()}; - } - - private UIButton createRunButton() { - run = new UIButton(BaseUtils.readIcon("com/fr/design/images/buttonicon/pageb24.png")) { - public Dimension getPreferredSize() { - return new Dimension(34, 43); - } - }; - run.setToolTipText(PREVIEW.getMenuKeySetName()); - run.set4ChartLargeToolButton(); - run.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - JTemplate jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); - if (jt == null) { - return; - } - onChartPreview(jt); - } - }); - return run; - } - - public static void onChartPreview(JTemplate jt) { - WebPreviewUtils.actionPerformed(jt, null, ParameterConsts.CHARTLET); - } - - public static final MenuKeySet PREVIEW = new MenuKeySet() { - @Override - public char getMnemonic() { - return 'P'; - } - - @Override - public String getMenuName() { - return Inter.getLocText("FR-Chart-Template_Preview"); - } - - @Override - public KeyStroke getKeyStroke() { - return KeyStroke.getKeyStroke(KeyEvent.VK_P, InputEvent.CTRL_MASK); - } - }; - - - private UIButton createCopyButton(){ - copy = new UIButton(BaseUtils.readIcon("com/fr/design/images/copyjs.png")) { - public Dimension getPreferredSize() { - return new Dimension(34, 43); - } - }; - copy.setToolTipText(Inter.getLocText("FR-Chart-Action_Copy")+"JS"); - copy.set4ChartLargeToolButton(); - copy.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - JTemplate jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); - if (jt == null) { - return; - } - DesignerContext.getDesignerFrame().refreshToolbar(); - - jt.stopEditing(); - if (!jt.isSaved() && !jt.saveTemplate2Env()) { - return; - } - //复制代码 - jt.copyJS(); - } - }); - return copy; - } - - private UIButton createSaveButton() { - saveButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/save.png")); - saveButton.setToolTipText(KeySetUtils.SAVE_TEMPLATE.getMenuKeySetName()); - saveButton.set4ToolbarButton(); - saveButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - JTemplate jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); - jt.stopEditing(); - jt.saveTemplate(); - jt.requestFocus(); - } - }); - return saveButton; - } - - private UIButton createUndoButton() { - undo = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/undo.png")); - undo.setToolTipText(KeySetUtils.UNDO.getMenuKeySetName()); - undo.set4ToolbarButton(); - undo.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - JTemplate jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); - if (jt != null) { - jt.undo(); - } - } - }); - return undo; - } - - private UIButton createRedoButton() { - redo = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/redo.png")); - redo.setToolTipText(KeySetUtils.REDO.getMenuKeySetName()); - redo.set4ToolbarButton(); - redo.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - JTemplate jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); - if (jt != null) { - jt.redo(); - } - } - }); - return redo; - } - - /** - * 重置工具条 - * @param toolbarComponent 工具栏 - * @param plus 对象 - * @return 工具条对象 - */ - public JComponent resetToolBar(JComponent toolbarComponent, ToolBarMenuDockPlus plus) { - return plus.toolBar4Authority(); - } - - public NewTemplatePane getNewTemplatePane(){ - return new NewTemplatePane() { - @Override - public Icon getNew() { - return BaseUtils.readIcon("/com/fr/design/images/newchart_normal.png"); - } - - @Override - public Icon getMouseOverNew() { - return BaseUtils.readIcon("/com/fr/design/images/newchart_over.png"); - } - - @Override - public Icon getMousePressNew() { - return BaseUtils.readIcon("/com/fr/design/images/newchart_press.png"); - } - }; - }; - - @Override - protected void refreshLargeToolbarState() { - JTemplate jt = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); - if (jt == null) { - return; - } - saveButton.setEnabled(!jt.isSaved()); - MutilTempalteTabPane.getInstance().refreshOpenedTemplate(HistoryTemplateListPane.getInstance().getHistoryList()); - MutilTempalteTabPane.getInstance().repaint(); - if (DesignerEnvManager.getEnvManager().isSupportUndo()) { - undo.setEnabled(jt.canUndo()); - redo.setEnabled(jt.canRedo()); - } else { - undo.setEnabled(false); - redo.setEnabled(false); - } - } - - protected SplashPane createSplashPane() { - return new ChartSplashPane(); - } - - /** - *更新工具栏 - */ - public void updateToolBarDef() { - refreshLargeToolbarState(); - } - - protected void addCloseCurrentTemplateAction(MenuDef menuDef) { - - } - - protected void addPreferenceAction(MenuDef menuDef) { - - } - - protected void addSwitchExistEnvAction(MenuDef menuDef) { - - } - - @Override - public MenuDef[] createTemplateShortCuts(ToolBarMenuDockPlus plus) { - MenuDef menuDef = new MenuDef(KeySetUtils.EXPORT_CHART.getMenuKeySetName(), KeySetUtils.EXPORT_CHART.getMnemonic()); - menuDef.addShortCut(plus.shortcut4ExportMenu()); - return new MenuDef[] {menuDef}; - } - - /** - * 创建帮助菜单得菜单项 - * @return 菜单项 - */ - public ShortCut[] createHelpShortCuts() { - resetToolTips(); - return new ShortCut[]{ - new ChartWebAction(), - SeparatorDef.DEFAULT, - new ChartFeedBackAciton(), - SeparatorDef.DEFAULT, - new UpdateOnlineAction(), - new AboutAction() - }; - } - - protected ShortCut openTemplateAction(){ - return new OpenChartAction(); - } - - protected String[] startFileSuffix(){ - return new String[]{".crt"}; - } - -} \ No newline at end of file diff --git a/designer_form/src/com/fr/design/mainframe/CoverReportPane.java b/designer_form/src/com/fr/design/mainframe/CoverReportPane.java index f996338562..ee1fb27bd1 100644 --- a/designer_form/src/com/fr/design/mainframe/CoverReportPane.java +++ b/designer_form/src/com/fr/design/mainframe/CoverReportPane.java @@ -44,17 +44,17 @@ public class CoverReportPane extends CoverPane implements HelpDialogHandler{ super(); this.helpMsg = helpMsg; add(controlButton); - if (WidgetPropertyPane.getInstance().getEditingFormDesigner() != null) { - WidgetPropertyPane.getInstance().getEditingFormDesigner().addDesignerEditListener(new DesignerEditListener() { - @Override - public void fireCreatorModified(DesignerEvent evt) { - if (evt.getCreatorEventID() == (DesignerEvent.CREATOR_DELETED) - || evt.getCreatorEventID() == (DesignerEvent.CREATOR_RESIZED)) { - destroyHelpDialog(); - } - } - }); - } +// if (WidgetPropertyPane.getInstance().getEditingFormDesigner() != null) { +// WidgetPropertyPane.getInstance().getEditingFormDesigner().addDesignerEditListener(new DesignerEditListener() { +// @Override +// public void fireCreatorModified(DesignerEvent evt) { +// if (evt.getCreatorEventID() == (DesignerEvent.CREATOR_DELETED) +// || evt.getCreatorEventID() == (DesignerEvent.CREATOR_RESIZED)) { +// destroyHelpDialog(); +// } +// } +// }); +// } } public String getHelpMsg() { diff --git a/designer_form/src/com/fr/design/mainframe/FormHierarchyTreePane.java b/designer_form/src/com/fr/design/mainframe/FormHierarchyTreePane.java index 006918ba93..91f92cba69 100644 --- a/designer_form/src/com/fr/design/mainframe/FormHierarchyTreePane.java +++ b/designer_form/src/com/fr/design/mainframe/FormHierarchyTreePane.java @@ -89,6 +89,12 @@ public class FormHierarchyTreePane extends FormDockView implements HierarchyTree public void refreshDockingView() { FormDesigner formDesigner = this.getEditingFormDesigner(); removeAll(); + if(this.componentTree != null) { + this.componentTree.removeAll(); + } + if(this.treeComboBox != null) { + this.treeComboBox.removeAll(); + } if (formDesigner == null) { clearDockingView(); return; From d2e367ac2a0d3d07627ff35d6bfd54c9ea13be7a Mon Sep 17 00:00:00 2001 From: daniel Date: Mon, 7 Nov 2016 14:47:12 +0800 Subject: [PATCH 14/22] level ++ --- designer_base/src/com/fr/design/fun/ElementUIProvider.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer_base/src/com/fr/design/fun/ElementUIProvider.java b/designer_base/src/com/fr/design/fun/ElementUIProvider.java index 7cdd8eb721..75c3c86e8a 100644 --- a/designer_base/src/com/fr/design/fun/ElementUIProvider.java +++ b/designer_base/src/com/fr/design/fun/ElementUIProvider.java @@ -13,7 +13,7 @@ public interface ElementUIProvider extends Mutable { String MARK_STRING = "ElementUIProvider"; - int CURRENT_LEVEL = 1; + int CURRENT_LEVEL = 2; /** * 单元格元素编辑器 From 985546787dc69e203aec4580d1bde9ad5aa6c2b8 Mon Sep 17 00:00:00 2001 From: Fangjie Hu Date: Mon, 7 Nov 2016 16:31:00 +0800 Subject: [PATCH 15/22] =?UTF-8?q?=E5=88=87=E6=8D=A2=E9=9D=A2=E6=9D=BF?= =?UTF-8?q?=E9=87=8D=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chart/gui/ChartTypeButtonPane.java | 18 ++++++++++++++---- .../mainframe/chart/gui/ChartTypePane.java | 13 +++++++++---- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java b/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java index 46722836af..0f23beb5d8 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java @@ -19,6 +19,7 @@ import com.fr.design.mainframe.chart.gui.ChartTypePane.ComboBoxPane; import com.fr.general.ComparatorUtils; import com.fr.general.FRLogger; import com.fr.general.Inter; +import com.fr.stable.StringUtils; import javax.swing.*; import java.awt.*; @@ -51,6 +52,7 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen private UITextField currentEditingEditor = null; private ChartTypePane parent = null; + private String lastPlotID = StringUtils.EMPTY; //记录鼠标当前是否在操作添加按钮 private boolean mouseOnChartTypeButtonPane = false; @@ -281,16 +283,18 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen return Inter.getLocText("FR-Chart-Types_Switch"); } + /** + * 返回是否还需要更新 + * @param name + * @return + */ private void changeCollectionSelected(String name) { if (editingCollection != null) { + lastPlotID = editingCollection.getSelectedChart().getPlot().getPlotID(); int count = editingCollection.getChartCount(); for (int i = 0; i < count; i++) { if (ComparatorUtils.equals(name, editingCollection.getChartName(i))) { editingCollection.setSelectedIndex(i); - //重构面板 - if (parent != null){ - parent.reLayoutEditPane(editingCollection.getSelectedChart()); - } break; } } @@ -509,6 +513,12 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen changeCollectionSelected(getButtonName()); setSelectedWithFireListener(true); fireSelectedChanged(); + + //需要先更新,最后重构面板 + //重构面板 + if (parent != null ){ + parent.reLayoutEditPane(lastPlotID, editingCollection); + } } } diff --git a/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypePane.java b/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypePane.java index a286b39c8c..eab0010eae 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypePane.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypePane.java @@ -262,12 +262,17 @@ public class ChartTypePane extends AbstractChartAttrPane{ } + /** - * 重构面板 - * @param chart + * 面板重构 + * @param lastPlotID + * @param collection */ - public void reLayoutEditPane(Chart chart){ - if (editPane != null){ + public void reLayoutEditPane(String lastPlotID, ChartCollection collection){ + Chart chart = collection.getSelectedChart(); + String plotID = chart.getPlot().getPlotID(); + boolean isUseDefault = ChartTypeInterfaceManager.getInstance().isUseDefaultPane(plotID); + if (editPane != null && editPane.isDefaultPane() != isUseDefault || (!isUseDefault && !ComparatorUtils.equals(lastPlotID, plotID))){ editPane.reLayout(chart); } } From a5a817f6a722ed592c4dde38f417e66a732f426d Mon Sep 17 00:00:00 2001 From: Fangjie Hu Date: Mon, 7 Nov 2016 17:17:03 +0800 Subject: [PATCH 16/22] update --- .../fr/design/mainframe/chart/gui/ChartTypeButtonPane.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java b/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java index a9626e5f54..9de951f4be 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java @@ -52,7 +52,6 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen private UITextField currentEditingEditor = null; private ChartTypePane parent = null; - private String lastPlotID = StringUtils.EMPTY; //记录鼠标当前是否在操作添加按钮 private boolean mouseOnChartTypeButtonPane = false; @@ -290,7 +289,6 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen */ private void changeCollectionSelected(String name) { if (editingCollection != null) { - lastPlotID = editingCollection.getSelectedChart().getPlot().getPlotID(); int count = editingCollection.getChartCount(); for (int i = 0; i < count; i++) { if (ComparatorUtils.equals(name, editingCollection.getChartName(i))) { @@ -510,6 +508,8 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen if (isEnabled()) { noSelected(); + //记录改变前的plotID + String lastPlotID = editingCollection == null ? StringUtils.EMPTY : editingCollection.getSelectedChart().getPlot().getPlotID(); changeCollectionSelected(getButtonName()); setSelectedWithFireListener(true); fireSelectedChanged(); From 3332fa12c40c3b8de78086cccb7bf4112fd8d66b Mon Sep 17 00:00:00 2001 From: Fangjie Hu Date: Mon, 7 Nov 2016 17:17:59 +0800 Subject: [PATCH 17/22] update --- .../fr/design/mainframe/chart/gui/ChartTypeButtonPane.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java b/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java index 9de951f4be..8ee4e4667f 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypeButtonPane.java @@ -282,11 +282,6 @@ public class ChartTypeButtonPane extends BasicBeanPane implemen return Inter.getLocText("FR-Chart-Types_Switch"); } - /** - * 返回是否还需要更新 - * @param name - * @return - */ private void changeCollectionSelected(String name) { if (editingCollection != null) { int count = editingCollection.getChartCount(); From 0529d6924a7e819198ff8604d17de2270938fa74 Mon Sep 17 00:00:00 2001 From: lee <854954082@qq.com> Date: Mon, 7 Nov 2016 18:28:18 +0800 Subject: [PATCH 18/22] 1 1 --- .../com/fr/design/extra/LoginWebBridge.java | 25 +++++----- .../com/fr/design/extra/PluginWebBridge.java | 13 ++++- .../design/extra/exe/PluginLoginExecutor.java | 49 +++++++++++++++++++ 3 files changed, 73 insertions(+), 14 deletions(-) create mode 100644 designer_base/src/com/fr/design/extra/exe/PluginLoginExecutor.java diff --git a/designer_base/src/com/fr/design/extra/LoginWebBridge.java b/designer_base/src/com/fr/design/extra/LoginWebBridge.java index b604ae8d8b..41ed99beb9 100644 --- a/designer_base/src/com/fr/design/extra/LoginWebBridge.java +++ b/designer_base/src/com/fr/design/extra/LoginWebBridge.java @@ -68,11 +68,11 @@ public class LoginWebBridge { public static com.fr.design.extra.LoginWebBridge getHelper() { if (helper != null) { - return helper; + return helper; } synchronized (com.fr.design.extra.LoginWebBridge.class) { if (helper == null) { - helper = new com.fr.design.extra.LoginWebBridge(); + helper = new com.fr.design.extra.LoginWebBridge(); } return helper; } @@ -118,14 +118,13 @@ public class LoginWebBridge { if(!StringUtils.isEmpty(this.userName)){ updateMessageCount(); } - DesignerEnvManager.getEnvManager().setBBSName(userName); this.userName = userName; } /** * 定时取后台论坛消息 */ - private void updateMessageCount(){ + public void updateMessageCount(){ //启动获取消息更新的线程 //登陆状态, 根据存起来的用户名密码, 每1分钟发起一次请求, 更新消息条数. Thread updateMessageThread = new Thread(new Runnable() { @@ -171,7 +170,7 @@ public class LoginWebBridge { } this.messageCount = count; StringBuilder sb = new StringBuilder(); - sb.append(StringUtils.BLANK).append(this.userName) + sb.append(StringUtils.BLANK).append(DesignerEnvManager.getEnvManager().getBBSName()) .append("(").append(this.messageCount) .append(")").append(StringUtils.BLANK); DesignerEnvManager.getEnvManager().setInShowBBsName(sb.toString()); @@ -244,7 +243,7 @@ public class LoginWebBridge { * @param uiLabel 两边的label显示 * @return 登录信息标志 */ - private String login(String username, String password, UILabel uiLabel) { + public String login(String username, String password, UILabel uiLabel) { if (!StringUtils.isNotBlank(username) && !StringUtils.isNotBlank(password)) { return LOGIN_INFO_EMPTY; } @@ -253,7 +252,7 @@ public class LoginWebBridge { } String loginResult = login(username, password); if (loginResult.equals(LOGININ)) { - updateUserInfo(username, password); + updateUserInfo(username); loginSuccess(username, uiLabel); setUserName(username, uiLabel); } @@ -275,10 +274,7 @@ public class LoginWebBridge { * @param username 用户名 * @param password 密码 */ - public void updateUserInfo(String username,String password) { - DesignerEnvManager.getEnvManager().setBBSName(username); - DesignerEnvManager.getEnvManager().setBBSPassword(password); - DesignerEnvManager.getEnvManager().setInShowBBsName(username); + public void updateUserInfo(String username) { this.userName = username; } @@ -309,7 +305,7 @@ public class LoginWebBridge { }); } - public String login(String username, String password) { + private String login(String username, String password) { try { Client uc = new Client(); String result = uc.uc_user_login(username, password); @@ -319,6 +315,9 @@ public class LoginWebBridge { int $uid = Integer.parseInt(list.get(0)); if ($uid > 0) { DesignerEnvManager.getEnvManager().setBbsUid($uid); + DesignerEnvManager.getEnvManager().setBBSName(username); + DesignerEnvManager.getEnvManager().setInShowBBsName(username); + DesignerEnvManager.getEnvManager().setBBSPassword(password); return LOGININ;//登录成功,0 } else if ($uid == -1) { return USERNAME_NOT_EXSIT;//用户名不存在,-1 @@ -335,4 +334,4 @@ public class LoginWebBridge { } return UNKNOWN_ERROR; } -} +} \ No newline at end of file diff --git a/designer_base/src/com/fr/design/extra/PluginWebBridge.java b/designer_base/src/com/fr/design/extra/PluginWebBridge.java index 12c3e85c41..15bd72c09c 100644 --- a/designer_base/src/com/fr/design/extra/PluginWebBridge.java +++ b/designer_base/src/com/fr/design/extra/PluginWebBridge.java @@ -529,6 +529,17 @@ public class PluginWebBridge { return LoginWebBridge.getHelper().pluginManageLogin(username, password, uiLabel); } + /** + * 插件管理部分的登陆的回调处理 + * @param username + * @param password + * @param callback + */ + public void defaultLogin(String username, String password, final JSObject callback) { + Task task = new PluginTask<>(webEngine, callback, new PluginLoginExecutor(username, password, uiLabel)); + new Thread(task).start(); + } + /** * 弹出QQ授权页面 */ @@ -545,4 +556,4 @@ public class PluginWebBridge { DesignerEnvManager.getEnvManager().setInShowBBsName(StringUtils.EMPTY); uiLabel.setText(Inter.getLocText("FR-Base_UnSignIn")); } -} +} \ No newline at end of file diff --git a/designer_base/src/com/fr/design/extra/exe/PluginLoginExecutor.java b/designer_base/src/com/fr/design/extra/exe/PluginLoginExecutor.java new file mode 100644 index 0000000000..c1101f8005 --- /dev/null +++ b/designer_base/src/com/fr/design/extra/exe/PluginLoginExecutor.java @@ -0,0 +1,49 @@ +package com.fr.design.extra.exe; + +import com.fr.design.extra.LoginWebBridge; +import com.fr.design.extra.Process; +import com.fr.design.gui.ilable.UILabel; + +/** + * Created by Slpire on 2016/11/7. + */ +public class PluginLoginExecutor implements Executor { + + private String result = "[]"; + + private String username; + private String password; + private UILabel uiLabel; + + public PluginLoginExecutor(String username, String password, UILabel uiLabel) { + this.username = username; + this.password = password; + this.uiLabel = uiLabel; + } + + @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) { + String loginResult = LoginWebBridge.getHelper().login(username, password, uiLabel); + if (Integer.valueOf(loginResult) == 0) { + LoginWebBridge.getHelper().updateMessageCount(); + } + result = loginResult; + } + } + }; + } +} From 46199cf5a75e7386f87af53c75c5882a688b4457 Mon Sep 17 00:00:00 2001 From: richie Date: Mon, 7 Nov 2016 18:54:08 +0800 Subject: [PATCH 19/22] =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E5=9B=BD?= =?UTF-8?q?=E9=99=85=E5=8C=96=E5=9C=A8web=E7=AB=AF=E5=8F=AF=E4=BB=A5?= =?UTF-8?q?=E4=BD=BF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/actions/file/LocalePane.java | 75 +++++++------------ 1 file changed, 28 insertions(+), 47 deletions(-) diff --git a/designer_base/src/com/fr/design/actions/file/LocalePane.java b/designer_base/src/com/fr/design/actions/file/LocalePane.java index 27dad46df9..3356fa70af 100644 --- a/designer_base/src/com/fr/design/actions/file/LocalePane.java +++ b/designer_base/src/com/fr/design/actions/file/LocalePane.java @@ -8,13 +8,7 @@ import java.awt.BorderLayout; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Properties; -import java.util.Set; -import java.util.Vector; +import java.util.*; import javax.swing.JTable; import javax.swing.RowFilter; @@ -31,10 +25,7 @@ import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.dialog.BasicPane; import com.fr.file.filetree.FileNode; -import com.fr.general.FRLogger; -import com.fr.general.GeneralUtils; -import com.fr.general.IOUtils; -import com.fr.general.Inter; +import com.fr.general.*; import com.fr.stable.ArrayUtils; import com.fr.stable.project.ProjectConstants; @@ -43,12 +34,6 @@ import com.fr.stable.project.ProjectConstants; * @since : 8.0 */ public class LocalePane extends BasicPane { - private static final String FR = "fr.properties"; - private static final String US = "fr_en_US.properties"; - private static final String CN = "fr_zh_CN.properties"; - private static final String JP = "fr_ja_JP.properties"; - private static final String TW = "fr_zh_TW.properties"; - private static final String KR = "fr_ko_KR.properties"; private static final String PREFIX = "fr_"; private static final int LOCALE_NAME_LEN = 5; @@ -124,39 +109,35 @@ public class LocalePane extends BasicPane { } private void initPredefinedProperties() { - Properties fr = loadLocaleProperties(FR); - Properties us = loadLocaleProperties(US); - Properties cn = loadLocaleProperties(CN); - Properties jp = loadLocaleProperties(JP); - Properties tw = loadLocaleProperties(TW); - Properties kr = loadLocaleProperties(KR); - - Set keys = fr.stringPropertyNames(); - List sortKeys = new ArrayList(keys); + Map map = Inter.getPredefinedPackageMap(); + LocalePackage chinese = map.get(Locale.SIMPLIFIED_CHINESE); + + List sortKeys = new ArrayList(); + + + Set bundles = chinese.getKindsOfResourceBundle(); + for (ResourceBundle bundle : bundles) { + sortKeys.addAll(bundle.keySet()); + } Collections.sort(sortKeys); - Vector keyVector = new Vector(); - Vector valueVector = new Vector(); - Vector usVector = new Vector(); - Vector cnVector = new Vector(); - Vector jpVector = new Vector(); - Vector twVector = new Vector(); - Vector krVector = new Vector(); - for (String key : sortKeys) { - keyVector.add(key); - valueVector.add(fr.getProperty(key)); - usVector.add(us.getProperty(key)); - cnVector.add(cn.getProperty(key)); - jpVector.add(jp.getProperty(key)); - twVector.add(tw.getProperty(key)); - krVector.add(kr.getProperty(key)); + + Map> data = new HashMap>(); + for (Map.Entry entry : map.entrySet()) { + Vector column = new Vector(); + for (String key : sortKeys) { + column.add(entry.getValue().getLocText(key)); + } + data.put(entry.getKey(), column); } + + Vector keyVector = new Vector(); + keyVector.addAll(sortKeys); + + predefineTableModel.addColumn(Inter.getLocText("Key"), keyVector); - predefineTableModel.addColumn(Inter.getLocText("Value"), valueVector); - predefineTableModel.addColumn("en_US", usVector); - predefineTableModel.addColumn("zh_CN", cnVector); - predefineTableModel.addColumn("ja_JP", jpVector); - predefineTableModel.addColumn("zh_TW", twVector); - predefineTableModel.addColumn("ko_KR", krVector); + for (Map.Entry> entry : data.entrySet()) { + predefineTableModel.addColumn(entry.getKey().getDisplayName(), entry.getValue()); + } } private void initCustomProperties() throws Exception { From 402d9e98c808f2cc8362163ccf874514549de6e1 Mon Sep 17 00:00:00 2001 From: PanLi320 <854954082@qq.com> Date: Mon, 7 Nov 2016 19:29:04 +0800 Subject: [PATCH 20/22] 1 1 --- designer/src/com/fr/design/mainframe/bbs/UserInfoLabel.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/designer/src/com/fr/design/mainframe/bbs/UserInfoLabel.java b/designer/src/com/fr/design/mainframe/bbs/UserInfoLabel.java index 79ca8b44d5..ddce30d70f 100644 --- a/designer/src/com/fr/design/mainframe/bbs/UserInfoLabel.java +++ b/designer/src/com/fr/design/mainframe/bbs/UserInfoLabel.java @@ -18,6 +18,7 @@ import com.fr.general.Inter; import com.fr.general.SiteCenter; import com.fr.general.http.HttpClient; import com.fr.stable.EncodeConstants; +import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import javax.swing.*; @@ -99,7 +100,9 @@ public class UserInfoLabel extends UILabel{ } }); - //PluginWebBridge.getHelper().setUILabel(UserInfoLabel.this); + if (StableUtils.getMajorJavaVersion() == 8) { + PluginWebBridge.getHelper().setUILabel(UserInfoLabel.this); + } QQLoginWebBridge.getHelper().setUILabelInPlugin(UserInfoLabel.this); UserLoginContext.addLoginContextListener(new LoginContextListener() { From 1ac33db0c254d05ec7a3381a714c89d8677cdf11 Mon Sep 17 00:00:00 2001 From: zhouping Date: Mon, 7 Nov 2016 19:29:49 +0800 Subject: [PATCH 21/22] =?UTF-8?q?REPORT-750=20=E8=A1=A8=E5=8D=95=E5=85=B1?= =?UTF-8?q?=E5=88=9B=E5=86=85=E6=B5=8B=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/designer/creator/XWAbsoluteBodyLayout.java | 10 ++++++++++ .../src/com/fr/design/mainframe/FormArea.java | 8 ++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/designer_form/src/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java b/designer_form/src/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java index b9fea0a0bf..e4008df6f1 100644 --- a/designer_form/src/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java +++ b/designer_form/src/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java @@ -42,4 +42,14 @@ public class XWAbsoluteBodyLayout extends XWAbsoluteLayout { public void setEditable(boolean isEditable) { super.setEditable(true); } + + /** + * 该组件是否可以拖拽(表单中绝对布局不可以拖拽) + * + * @return 是则返回true + */ + @Override + public boolean isSupportDrag() { + return false; + } } diff --git a/designer_form/src/com/fr/design/mainframe/FormArea.java b/designer_form/src/com/fr/design/mainframe/FormArea.java index 26f3b04903..4f6c86feef 100644 --- a/designer_form/src/com/fr/design/mainframe/FormArea.java +++ b/designer_form/src/com/fr/design/mainframe/FormArea.java @@ -433,17 +433,17 @@ public class FormArea extends JComponent implements ScrollRulerComponent { if (rec.width <= dWidth&&rec.x < getHorizontalValue()) { //在边界内部且x位置小于水平滚动条的值 horScrollBar.setValue(rec.x); - } else if (rec.x+rec.width > dWidth) { + } else if (rec.x + rec.width > dWidth + horizontalValue) { //超出边界宽度 - horScrollBar.setValue(rec.x+rec.width-dWidth); + horScrollBar.setValue(rec.x + rec.width - dWidth); } int dHeight = getDesignerHeight(); if (rec.height < dHeight && rec.y < getVerticalValue()) { //在边界内部且y位置小于竖直滚动条的值 verScrollBar.setValue(rec.y); - } else if (rec.y+rec.height > dHeight) { + } else if (rec.y + rec.height > dHeight + verticalValue) { //超出边界高度 - verScrollBar.setValue(rec.y+rec.height-dHeight); + verScrollBar.setValue(rec.y + rec.height - dHeight); } } From 100bcc4216b76994ca991b89ca1608d1ebbc4ca6 Mon Sep 17 00:00:00 2001 From: eason-skx Date: Tue, 8 Nov 2016 10:29:11 +0800 Subject: [PATCH 22/22] =?UTF-8?q?=E5=88=A0import?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/design/file/HistoryTemplateListPane.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/designer_base/src/com/fr/design/file/HistoryTemplateListPane.java b/designer_base/src/com/fr/design/file/HistoryTemplateListPane.java index 50cdf00cf9..c61a39c431 100644 --- a/designer_base/src/com/fr/design/file/HistoryTemplateListPane.java +++ b/designer_base/src/com/fr/design/file/HistoryTemplateListPane.java @@ -9,8 +9,6 @@ import java.util.logging.Level; import javax.swing.*; -import com.fr.chart.chartattr.ChartCollection; -import com.fr.design.actions.core.ActionFactory; import com.fr.design.constants.UIConstants; import com.fr.design.DesignerEnvManager; import com.fr.design.data.DesignTableDataManager;