From d7dfacd2f630cf4cd927b21ce97ae06b4a577ec2 Mon Sep 17 00:00:00 2001 From: kerry Date: Mon, 6 Mar 2017 16:48:40 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E6=97=A0jira=E4=BB=BB=E5=8A=A1=EF=BC=8C?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=E5=9B=BD=E9=99=85=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/design/locale/designer.properties | 13 ++++++++++++- .../com/fr/design/locale/designer_en_US.properties | 13 ++++++++++++- .../com/fr/design/locale/designer_ja_JP.properties | 11 +++++++++++ .../com/fr/design/locale/designer_ko_KR.properties | 11 +++++++++++ .../com/fr/design/locale/designer_zh_CN.properties | 13 ++++++++++++- .../com/fr/design/locale/designer_zh_TW.properties | 13 ++++++++++++- 6 files changed, 70 insertions(+), 4 deletions(-) diff --git a/designer_base/src/com/fr/design/locale/designer.properties b/designer_base/src/com/fr/design/locale/designer.properties index 0a66c326e8..87a3471e95 100644 --- a/designer_base/src/com/fr/design/locale/designer.properties +++ b/designer_base/src/com/fr/design/locale/designer.properties @@ -567,4 +567,15 @@ FR-Designer_Parameter-Formula=Formula FR-Designer_Plugin_Should_Update_Please_Contact_Developer=Plugin version is too low, and is not compatible with current API. Please contact the developer to update. FR-Designer_WidgetOrder=Widget Order FR-Designer_Mobile_Form_Analysis_Annotation=annotation\: You can use this attribute to control the analysis of the form in the APP. -FR-Designer_Mobile_Report_Analysis_Annotation=annotation\: You can use this attribute to control the analysis of the report in the APP, only to support the paging preview, fill in the preview of the property is invalid. \ No newline at end of file +FR-Designer_Mobile_Report_Analysis_Annotation=annotation\: You can use this attribute to control the analysis of the report in the APP, only to support the paging preview, fill in the preview of the property is invalid. +FR-Designer_Background_Null= +FR-Designer_Background_Color= +FR-Designer_Background_Texture= +FR-Designer_Background_Pattern= +FR-Designer_Background_Gradient_Color= +FR-Designer_Background_Image= +FR-Designer_Background_Clear= +FR-Designer_Background_Image_Select= +FR-Designer_Initial_Background_Tips= +FR-Designer_Mouse_Move_Tips= +FR-Designer_Mouse_Click_Tips= \ No newline at end of file diff --git a/designer_base/src/com/fr/design/locale/designer_en_US.properties b/designer_base/src/com/fr/design/locale/designer_en_US.properties index b0acea3ab4..aedaabbc68 100644 --- a/designer_base/src/com/fr/design/locale/designer_en_US.properties +++ b/designer_base/src/com/fr/design/locale/designer_en_US.properties @@ -568,4 +568,15 @@ FR-Designer_Parameter-Formula=Formula FR-Designer_Plugin_Should_Update_Please_Contact_Developer=Plugin version is too low, and is not compatible with current API. Please contact the developer to update. FR-Designer_WidgetOrder=Widget Order FR-Designer_Mobile_Form_Analysis_Annotation=annotation\: You can use this attribute to control the analysis of the form in the APP. -FR-Designer_Mobile_Report_Analysis_Annotation=annotation\: You can use this attribute to control the analysis of the report in the APP, only to support the paging preview, fill in the preview of the property is invalid. \ No newline at end of file +FR-Designer_Mobile_Report_Analysis_Annotation=annotation\: You can use this attribute to control the analysis of the report in the APP, only to support the paging preview, fill in the preview of the property is invalid. +FR-Designer_Background_Null=No Background +FR-Designer_Background_Color=Color +FR-Designer_Background_Texture=Texture +FR-Designer_Background_Pattern=Pattern +FR-Designer_Background_Gradient_Color=Gradient Color +FR-Designer_Background_Image=Image +FR-Designer_Background_Clear=Clear +FR-Designer_Background_Image_Select=Select Picture +FR-Designer_Initial_Background_Tips=Initial background of the button +FR-Designer_Mouse_Move_Tips=Move the mouse to the button on the background, in the absence of not changing the background +FR-Designer_Mouse_Click_Tips=The background of the mouse to click the button, in the absence of not changing the background \ No newline at end of file diff --git a/designer_base/src/com/fr/design/locale/designer_ja_JP.properties b/designer_base/src/com/fr/design/locale/designer_ja_JP.properties index d86d0a164c..f966aaef05 100644 --- a/designer_base/src/com/fr/design/locale/designer_ja_JP.properties +++ b/designer_base/src/com/fr/design/locale/designer_ja_JP.properties @@ -539,3 +539,14 @@ FR-Designer_No=\u3044\u3044\u3048 FR-Designer_Pagination=\u30DA\u30FC\u30B8\u30F3\u30B0 FR-Designer_DS_TableData=\u30C7\u30FC\u30BF\u30BD\u30FC\u30B9 FR-Designer_Parameter-Formula=\u6570\u5F0F +FR-Designer_Background_Null= +FR-Designer_Background_Color= +FR-Designer_Background_Texture= +FR-Designer_Background_Pattern= +FR-Designer_Background_Gradient_Color= +FR-Designer_Background_Image= +FR-Designer_Background_Clear= +FR-Designer_Background_Image_Select= +FR-Designer_Initial_Background_Tips= +FR-Designer_Mouse_Move_Tips= +FR-Designer_Mouse_Click_Tips= diff --git a/designer_base/src/com/fr/design/locale/designer_ko_KR.properties b/designer_base/src/com/fr/design/locale/designer_ko_KR.properties index dfb5ec78ff..611d8128c9 100644 --- a/designer_base/src/com/fr/design/locale/designer_ko_KR.properties +++ b/designer_base/src/com/fr/design/locale/designer_ko_KR.properties @@ -536,3 +536,14 @@ FR-Designer_No=\uC544\uB2C8\uC624 FR-Designer_Pagination=\uD398\uC774\uC9C0\uB098\uB204\uAE30 FR-Designer_DS_TableData=\uB370\uC774\uD130\uC138\uD2B8 FR-Designer_Parameter-Formula=\uC218\uC2DD +FR-Designer_Background_Null= +FR-Designer_Background_Color= +FR-Designer_Background_Texture= +FR-Designer_Background_Pattern= +FR-Designer_Background_Gradient_Color= +FR-Designer_Background_Image= +FR-Designer_Background_Clear= +FR-Designer_Background_Image_Select= +FR-Designer_Initial_Background_Tips= +FR-Designer_Mouse_Move_Tips= +FR-Designer_Mouse_Click_Tips= \ No newline at end of file diff --git a/designer_base/src/com/fr/design/locale/designer_zh_CN.properties b/designer_base/src/com/fr/design/locale/designer_zh_CN.properties index bdb97b094e..0bf1d423c4 100644 --- a/designer_base/src/com/fr/design/locale/designer_zh_CN.properties +++ b/designer_base/src/com/fr/design/locale/designer_zh_CN.properties @@ -572,4 +572,15 @@ FR-Designer_Parameter-Formula=\u516C\u5F0F FR-Designer_Plugin_Should_Update_Please_Contact_Developer=\u63D2\u4EF6\u7248\u672C\u8FC7\u4F4E, \u5B58\u5728API\u4E0D\u517C\u5BB9, \u8BF7\u8054\u7CFB\u5F00\u53D1\u8005\u5347\u7EA7\u63D2\u4EF6 FR-Designer_WidgetOrder=\u63A7\u4EF6\u987A\u5E8F FR-Designer_Mobile_Form_Analysis_Annotation=\u6CE8\u91CA\uFF1A\u53EF\u4EE5\u901A\u8FC7\u8BE5\u5C5E\u6027\u63A7\u5236\u8868\u5355\u5728APP\u4E2D\u7684\u89E3\u6790\u65B9\u5F0F\u3002 -FR-Designer_Mobile_Report_Analysis_Annotation=\u6CE8\u91CA\: \u53EF\u4EE5\u901A\u8FC7\u8BE5\u5C5E\u6027\u63A7\u5236\u62A5\u8868\u5728APP\u4E2D\u7684\u89E3\u6790\u65B9\u5F0F\uFF0C\u53EA\u652F\u6301\u5206\u9875\u9884\u89C8\uFF0C\u586B\u62A5\u9884\u89C8\u65F6\u5C5E\u6027\u65E0\u6548\u3002 \ No newline at end of file +FR-Designer_Mobile_Report_Analysis_Annotation=\u6CE8\u91CA\: \u53EF\u4EE5\u901A\u8FC7\u8BE5\u5C5E\u6027\u63A7\u5236\u62A5\u8868\u5728APP\u4E2D\u7684\u89E3\u6790\u65B9\u5F0F\uFF0C\u53EA\u652F\u6301\u5206\u9875\u9884\u89C8\uFF0C\u586B\u62A5\u9884\u89C8\u65F6\u5C5E\u6027\u65E0\u6548\u3002 +FR-Designer_Background_Null=\u6CA1\u6709\u80CC\u666F +FR-Designer_Background_Color=\u989C\u8272 +FR-Designer_Background_Texture=\u7EB9\u7406 +FR-Designer_Background_Pattern=\u56FE\u6848 +FR-Designer_Background_Gradient_Color=\u6E10\u53D8\u8272 +FR-Designer_Background_Image=\u56FE\u7247 +FR-Designer_Background_Clear=\u6E05\u9664 +FR-Designer_Background_Image_Select=\u9009\u62E9\u56FE\u7247 +FR-Designer_Initial_Background_Tips=\u6309\u94AE\u7684\u521D\u59CB\u80CC\u666F +FR-Designer_Mouse_Move_Tips=\u9F20\u6807\u79FB\u52A8\u5230\u6309\u94AE\u4E0A\u7684\u80CC\u666F\uFF0C\u82E5\u65E0\u5219\u4E0D\u6539\u53D8\u80CC\u666F +FR-Designer_Mouse_Click_Tips=\u9F20\u6807\u70B9\u51FB\u6309\u94AE\u65F6\u80CC\u666F\uFF0C\u82E5\u65E0\u5219\u4E0D\u6539\u53D8\u80CC\u666F \ No newline at end of file diff --git a/designer_base/src/com/fr/design/locale/designer_zh_TW.properties b/designer_base/src/com/fr/design/locale/designer_zh_TW.properties index 3acd7487c2..47836061f4 100644 --- a/designer_base/src/com/fr/design/locale/designer_zh_TW.properties +++ b/designer_base/src/com/fr/design/locale/designer_zh_TW.properties @@ -560,4 +560,15 @@ FR-Designer_Parameter-Formula=\u516C\u5F0F FR-Designer_Plugin_Should_Update_Please_Contact_Developer=\u63D2\u4EF6\u7248\u672C\u904E\u4F4E, \u5B58\u5728API\u4E0D\u517C\u5BB9, \u8ACB\u806F\u7E6B\u958B\u767C\u8005\u5347\u7D1A\u63D2\u4EF6 FR-Designer_WidgetOrder=\u63A7\u4EF6\u9806\u5E8F FR-Designer_Mobile_Form_Analysis_Annotation=\u6CE8\u91CB\uFF1A\u53EF\u4EE5\u901A\u904E\u8A72\u5C6C\u6027\u63A7\u5236\u8868\u55AE\u5728APP\u4E2D\u7684\u89E3\u6790\u65B9\u5F0F\u3002 -FR-Designer_Mobile_Report_Analysis_Annotation=\u6CE8\u91CB\uFF1A\u53EF\u4EE5\u901A\u904E\u8A72\u5C6C\u6027\u63A7\u5236\u5831\u8868\u5728APP\u4E2D\u7684\u89E3\u6790\u65B9\u5F0F\uFF0C\u53EA\u652F\u6301\u5206\u9801\u9810\u89BD\uFF0C\u586B\u5831\u9810\u89BD\u6642\u5C6C\u6027\u7121\u6548\u3002 \ No newline at end of file +FR-Designer_Mobile_Report_Analysis_Annotation=\u6CE8\u91CB\uFF1A\u53EF\u4EE5\u901A\u904E\u8A72\u5C6C\u6027\u63A7\u5236\u5831\u8868\u5728APP\u4E2D\u7684\u89E3\u6790\u65B9\u5F0F\uFF0C\u53EA\u652F\u6301\u5206\u9801\u9810\u89BD\uFF0C\u586B\u5831\u9810\u89BD\u6642\u5C6C\u6027\u7121\u6548\u3002 +FR-Designer_Background_Null= +FR-Designer_Background_Color= +FR-Designer_Background_Texture= +FR-Designer_Background_Pattern= +FR-Designer_Background_Gradient_Color= +FR-Designer_Background_Image= +FR-Designer_Background_Clear= +FR-Designer_Background_Image_Select= +FR-Designer_Initial_Background_Tips= +FR-Designer_Mouse_Move_Tips= +FR-Designer_Mouse_Click_Tips= \ No newline at end of file From ab1d6e5cc7ea54fb0696e0cf285e34d935e5f64f Mon Sep 17 00:00:00 2001 From: plough Date: Thu, 6 Apr 2017 10:04:10 +0800 Subject: [PATCH 2/8] =?UTF-8?q?REPORT-1916=20=E6=A8=A1=E6=9D=BF=E8=80=97?= =?UTF-8?q?=E6=97=B6=3D=E3=80=8B=E8=BF=9C=E7=A8=8B=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E6=97=B6=E4=B8=8D=E6=94=B6=E9=9B=86=E6=A8=A1=E6=9D=BF=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/mainframe/templateinfo/TemplateInfoCollector.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/designer_base/src/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java b/designer_base/src/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java index 3cbc557f81..f302d9f5ea 100644 --- a/designer_base/src/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java +++ b/designer_base/src/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java @@ -5,6 +5,7 @@ import com.fr.base.io.IOFile; import com.fr.design.DesignerEnvManager; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.JTemplate; +import com.fr.env.RemoteEnv; import com.fr.general.ComparatorUtils; import com.fr.general.FRLogger; import com.fr.general.GeneralUtils; @@ -78,7 +79,9 @@ public class TemplateInfoCollector implements Serializable { } private boolean shouldCollectInfo(T t) { - if (t.getTemplateID() == null || instance.removedTemplates.contains(t.getTemplateID())) { // 旧模板 + if (FRContext.getCurrentEnv() instanceof RemoteEnv // 远程设计不收集数据 + || t.getTemplateID() == null + || instance.removedTemplates.contains(t.getTemplateID())) { // 旧模板 return false; } return DesignerEnvManager.getEnvManager().isJoinProductImprove() && FRContext.isChineseEnv(); From 4cd9b17bfca1021f81e616f035daef7fc7941851 Mon Sep 17 00:00:00 2001 From: plough Date: Thu, 6 Apr 2017 10:36:56 +0800 Subject: [PATCH 3/8] =?UTF-8?q?REPORT-1916=20=E6=A8=A1=E6=9D=BF=E8=80=97?= =?UTF-8?q?=E6=97=B6=3D=E3=80=8B=E5=A6=82=E6=9E=9C=20TemplateInfoCollecor?= =?UTF-8?q?=20=E7=B1=BB=E7=BB=93=E6=9E=84=E6=9C=89=E6=94=B9=E5=8A=A8?= =?UTF-8?q?=EF=BC=8C=E5=88=99=E6=94=BE=E5=BC=83=E4=B9=8B=E5=89=8D=E6=94=B6?= =?UTF-8?q?=E9=9B=86=E7=9A=84=E6=95=B0=E6=8D=AE=EF=BC=8C=E4=BF=9D=E8=AF=81?= =?UTF-8?q?=E6=AD=A3=E5=B8=B8=E5=90=AF=E5=8A=A8=E8=AE=BE=E8=AE=A1=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/templateinfo/TemplateInfoCollector.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/designer_base/src/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java b/designer_base/src/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java index f302d9f5ea..76d942e9a3 100644 --- a/designer_base/src/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java +++ b/designer_base/src/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java @@ -71,7 +71,14 @@ public class TemplateInfoCollector implements Serializable { } catch (FileNotFoundException ex) { // 如果之前没有存储过,则创建新对象 instance = new TemplateInfoCollector(); - } catch (Exception ex) { + } catch (InvalidClassException ex) { + // 如果 TemplateInfoCollecor 类结构有改动,则放弃之前收集的数据(下次保存时覆盖) + // 这种情况主要在开发、测试过程中遇到,正式上线后不应该出现 + FRLogger.getLogger().error(ex.getMessage()); + FRLogger.getLogger().info("use a new instance"); + instance = new TemplateInfoCollector(); + } + catch (Exception ex) { FRLogger.getLogger().error(ex.getMessage(), ex); } } From cebfc9ef10d1c3411e4bc6a33e3b05d38b158e53 Mon Sep 17 00:00:00 2001 From: plough Date: Thu, 6 Apr 2017 12:47:09 +0800 Subject: [PATCH 4/8] =?UTF-8?q?REPORT-1916=20=E6=A8=A1=E6=9D=BF=E8=80=97?= =?UTF-8?q?=E6=97=B6=3D=E3=80=8B=E4=BF=AE=E6=94=B9=E7=AE=97=E6=B3=95?= =?UTF-8?q?=EF=BC=8C=E5=B0=86=E4=B8=8A=E4=BC=A0=E5=90=8E=E7=9A=84=E6=A8=A1?= =?UTF-8?q?=E6=9D=BF=E8=A7=86=E4=B8=BA=E6=97=A7=E6=A8=A1=E6=9D=BF=EF=BC=8C?= =?UTF-8?q?=E4=B8=8D=E5=86=8D=E6=94=B6=E9=9B=86=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/design/mainframe/JTemplate.java | 3 +++ .../templateinfo/TemplateInfoCollector.java | 16 +++++----------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/designer_base/src/com/fr/design/mainframe/JTemplate.java b/designer_base/src/com/fr/design/mainframe/JTemplate.java index 37769cdbe8..7c98fecd1f 100644 --- a/designer_base/src/com/fr/design/mainframe/JTemplate.java +++ b/designer_base/src/com/fr/design/mainframe/JTemplate.java @@ -117,6 +117,9 @@ public abstract class JTemplate> ex } } private void collectInfo() { // 执行收集操作 + if (openTime == 0) { // 旧模板,不收集数据 + return; + } long saveTime = System.currentTimeMillis(); // 保存模板的时间点 tic.collectInfo(template, this, openTime, saveTime); openTime = saveTime; // 更新 openTime,准备下一次计算 diff --git a/designer_base/src/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java b/designer_base/src/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java index 76d942e9a3..db1fe312ae 100644 --- a/designer_base/src/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java +++ b/designer_base/src/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java @@ -26,7 +26,6 @@ public class TemplateInfoCollector implements Serializable { private static final String FILE_NAME = "tplInfo.ser"; private static TemplateInfoCollector instance; private HashMap> templateInfoList; - private Set removedTemplates; // 已经从 templateInfoList 中删除过的 id 列表,防止重复收集数据 private String designerOpenDate; //设计器最近一次打开日期 private static final int VALID_CELL_COUNT = 5; // 有效报表模板的格子数 private static final int VALID_WIDGET_COUNT = 5; // 有效报表模板的控件数 @@ -36,7 +35,6 @@ public class TemplateInfoCollector implements Serializable { @SuppressWarnings("unchecked") private TemplateInfoCollector() { templateInfoList = new HashMap<>(); - removedTemplates = new ListSet<>(); setDesignerOpenDate(); } @@ -85,17 +83,15 @@ public class TemplateInfoCollector implements Serializable { return instance; } - private boolean shouldCollectInfo(T t) { - if (FRContext.getCurrentEnv() instanceof RemoteEnv // 远程设计不收集数据 - || t.getTemplateID() == null - || instance.removedTemplates.contains(t.getTemplateID())) { // 旧模板 + private boolean shouldCollectInfo() { + if (FRContext.getCurrentEnv() instanceof RemoteEnv) { // 远程设计不收集数据 return false; } return DesignerEnvManager.getEnvManager().isJoinProductImprove() && FRContext.isChineseEnv(); } - public void appendProcess(T t, String log) { - if (!shouldCollectInfo(t)) { + public void appendProcess(String log) { + if (!shouldCollectInfo()) { return; } // 获取当前编辑的模板 @@ -161,7 +157,7 @@ public class TemplateInfoCollector implements Serializable { */ @SuppressWarnings("unchecked") public void collectInfo(T t, JTemplate jt, long openTime, long saveTime) { - if (!shouldCollectInfo(t)) { + if (!shouldCollectInfo()) { return; } @@ -304,9 +300,7 @@ public class TemplateInfoCollector implements Serializable { private void removeFromTemplateInfoList(String key) { templateInfoList.remove(key); - removedTemplates.add(key); FRLogger.getLogger().info(key + " is removed..."); - FRLogger.getLogger().info("removedTemplates: " + removedTemplates); } @SuppressWarnings("unchecked") From 88201d9d5c175775f43cb017f3d8b5159ee3bf4f Mon Sep 17 00:00:00 2001 From: plough Date: Thu, 6 Apr 2017 14:42:21 +0800 Subject: [PATCH 5/8] =?UTF-8?q?REPORT-1916=20=E6=A8=A1=E6=9D=BF=E8=80=97?= =?UTF-8?q?=E6=97=B6=3D=E3=80=8B=E8=B0=83=E6=95=B4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=EF=BC=9B=E5=8F=91=E9=80=81=E6=95=B0=E6=8D=AE=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E8=BE=93=E5=87=BA=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer_base/src/com/fr/design/mainframe/JTemplate.java | 4 ++-- .../design/mainframe/templateinfo/TemplateInfoCollector.java | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/designer_base/src/com/fr/design/mainframe/JTemplate.java b/designer_base/src/com/fr/design/mainframe/JTemplate.java index 7c98fecd1f..92dd63e112 100644 --- a/designer_base/src/com/fr/design/mainframe/JTemplate.java +++ b/designer_base/src/com/fr/design/mainframe/JTemplate.java @@ -85,7 +85,7 @@ public abstract class JTemplate> ex public JTemplate(T t, String defaultFileName) { this(t, new MemFILE(newTemplateNameByIndex(defaultFileName)), true); - initForCollect(); + openTime = System.currentTimeMillis(); } public JTemplate(T t, FILE file) { @@ -534,7 +534,7 @@ public abstract class JTemplate> ex boolean result = this.saveFile(); if (result) { DesignerFrameFileDealerPane.getInstance().refresh(); - initForCollect(); // 如果另存为新模板,则添加 templateID + initForCollect(); // 如果保存新模板(新建模板直接保存,或者另存为),则添加 templateID collectInfo(); } //更换最近打开 diff --git a/designer_base/src/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java b/designer_base/src/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java index db1fe312ae..1b57c21fa9 100644 --- a/designer_base/src/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java +++ b/designer_base/src/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java @@ -242,6 +242,8 @@ public class TemplateInfoCollector implements Serializable { // 清空记录 FRLogger.getLogger().info("successfully send " + templateInfo.get("templateID")); removeFromTemplateInfoList(templateInfo.get("templateID")); + } else { + FRLogger.getLogger().info("模板数据发送服务器失败,下次启动设计器时再尝试:" + templateInfo.get("templateID")); } } saveInfo(); From 139b3b89e24e57e2bcdf663e1b1940bfbafbe6d8 Mon Sep 17 00:00:00 2001 From: plough Date: Thu, 6 Apr 2017 14:45:08 +0800 Subject: [PATCH 6/8] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/mainframe/templateinfo/TemplateInfoCollector.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer_base/src/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java b/designer_base/src/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java index 1b57c21fa9..37446b3d34 100644 --- a/designer_base/src/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java +++ b/designer_base/src/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java @@ -243,7 +243,7 @@ public class TemplateInfoCollector implements Serializable { FRLogger.getLogger().info("successfully send " + templateInfo.get("templateID")); removeFromTemplateInfoList(templateInfo.get("templateID")); } else { - FRLogger.getLogger().info("模板数据发送服务器失败,下次启动设计器时再尝试:" + templateInfo.get("templateID")); + FRLogger.getLogger().info("send template info failed, will try next time, " + templateInfo.get("templateID")); } } saveInfo(); From eb465d65f5fefd70787773ced1a97eecada6476d Mon Sep 17 00:00:00 2001 From: plough Date: Fri, 7 Apr 2017 11:43:29 +0800 Subject: [PATCH 7/8] =?UTF-8?q?REPORT-1916=20=E6=A8=A1=E6=9D=BF=E8=80=97?= =?UTF-8?q?=E6=97=B6=3D=E3=80=8B=E7=BB=99TemplateInfoCollector=E5=8A=A0?= =?UTF-8?q?=E4=B8=8AserialVersionUID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/mainframe/templateinfo/TemplateInfoCollector.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/designer_base/src/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java b/designer_base/src/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java index 37446b3d34..b9b7aa194e 100644 --- a/designer_base/src/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java +++ b/designer_base/src/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java @@ -31,6 +31,7 @@ public class TemplateInfoCollector implements Serializable { private static final int VALID_WIDGET_COUNT = 5; // 有效报表模板的控件数 private static final int COMPLETE_DAY_COUNT = 15; // 判断模板是否完成的天数 private static final int ONE_THOUSAND = 1000; + static final long serialVersionUID = 2007L; @SuppressWarnings("unchecked") private TemplateInfoCollector() { @@ -72,7 +73,7 @@ public class TemplateInfoCollector implements Serializable { } catch (InvalidClassException ex) { // 如果 TemplateInfoCollecor 类结构有改动,则放弃之前收集的数据(下次保存时覆盖) // 这种情况主要在开发、测试过程中遇到,正式上线后不应该出现 - FRLogger.getLogger().error(ex.getMessage()); + FRLogger.getLogger().info(ex.getMessage()); FRLogger.getLogger().info("use a new instance"); instance = new TemplateInfoCollector(); } From 58fbac4e191af1d56f843ac75f020eba3f405c1c Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Fri, 7 Apr 2017 13:58:25 +0800 Subject: [PATCH 8/8] =?UTF-8?q?report-1945=E7=BB=84=E4=BB=B6=E5=A4=8D?= =?UTF-8?q?=E7=94=A8bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/locale/designer.properties | 2 + .../design/locale/designer_en_US.properties | 2 + .../design/locale/designer_zh_CN.properties | 3 +- .../design/locale/designer_zh_TW.properties | 3 +- .../layout/FRAbsoluteLayoutAdapter.java | 11 +- .../adapters/layout/FRBodyLayoutAdapter.java | 26 +- .../adapters/layout/FRFitLayoutAdapter.java | 2 +- .../layout/FRTabFitLayoutAdapter.java | 15 +- .../designer/beans/models/AddingModel.java | 180 ++--- .../designer/beans/models/SelectionModel.java | 46 +- .../designer/beans/models/StateModel.java | 688 +++++++++--------- .../beans/painters/AbstractPainter.java | 45 +- .../designer/creator/XLayoutContainer.java | 435 +++++------ .../creator/cardlayout/XWCardTagLayout.java | 338 +++++---- .../mainframe/FormCreatorDropTarget.java | 17 +- .../com/fr/design/mainframe/FormDesigner.java | 6 + .../fr/design/mainframe/FormSelection.java | 12 +- .../design/mainframe/FormSelectionUtils.java | 73 +- 18 files changed, 985 insertions(+), 919 deletions(-) diff --git a/designer_base/src/com/fr/design/locale/designer.properties b/designer_base/src/com/fr/design/locale/designer.properties index 7c4847f3ca..0eda01dee6 100644 --- a/designer_base/src/com/fr/design/locale/designer.properties +++ b/designer_base/src/com/fr/design/locale/designer.properties @@ -585,3 +585,5 @@ FR-Designer-Move_Tab_First=move to first FR-Designer-Move_Tab_End=move to end FR-Designer-Move_Tab_Next=move to next FR-Designer-Move_Tab_Prev=move to previous +FR-Designer_Too_Large_To_Paste=too large to paste +FR-Designer_Too_Small_To_Paste=Too small to paste diff --git a/designer_base/src/com/fr/design/locale/designer_en_US.properties b/designer_base/src/com/fr/design/locale/designer_en_US.properties index fab277ad6f..0dc0c050f9 100644 --- a/designer_base/src/com/fr/design/locale/designer_en_US.properties +++ b/designer_base/src/com/fr/design/locale/designer_en_US.properties @@ -586,3 +586,5 @@ FR-Designer-Move_Tab_First=move to first FR-Designer-Move_Tab_End=move to end FR-Designer-Move_Tab_Next=move to next FR-Designer-Move_Tab_Prev=move to previous +FR-Designer_Too_Large_To_Paste=Too large to paste! +FR-Designer_Too_Small_To_Paste=Too small to paste! diff --git a/designer_base/src/com/fr/design/locale/designer_zh_CN.properties b/designer_base/src/com/fr/design/locale/designer_zh_CN.properties index 56e695b2cf..5631325835 100644 --- a/designer_base/src/com/fr/design/locale/designer_zh_CN.properties +++ b/designer_base/src/com/fr/design/locale/designer_zh_CN.properties @@ -585,9 +585,10 @@ FR-Designer_Background_Clear=\u6E05\u9664 FR-Designer_Background_Image_Select=\u9009\u62E9\u56FE\u7247 FR-Designer_Initial_Background_Tips=\u6309\u94AE\u7684\u521D\u59CB\u80CC\u666F FR-Designer_Mouse_Move_Tips=\u9F20\u6807\u79FB\u52A8\u5230\u6309\u94AE\u4E0A\u7684\u80CC\u666F\uFF0C\u82E5\u65E0\u5219\u4E0D\u6539\u53D8\u80CC\u666F - FR-Designer_Mouse_Click_Tips=\u9F20\u6807\u70B9\u51FB\u6309\u94AE\u65F6\u80CC\u666F\uFF0C\u82E5\u65E0\u5219\u4E0D\u6539\u53D8\u80CC\u666F FR-Designer-Move_Tab_First=\u79FB\u52A8\u5230\u9996\u4F4D FR-Designer-Move_Tab_End=\u79FB\u52A8\u5230\u672B\u5C3E FR-Designer-Move_Tab_Next=\u5F80\u540E\u79FB\u52A8 FR-Designer-Move_Tab_Prev=\u5F80\u524D\u79FB\u52A8 +FR-Designer_Too_Large_To_Paste=\u7EC4\u4EF6\u5927\u5C0F\u8D85\u51FA\u8FB9\u754C\uFF0C\u65E0\u6CD5\u7C98\u8D34\uFF01 +FR-Designer_Too_Small_To_Paste=\u6B64\u5904\u65E0\u6CD5\u7C98\u8D34\uFF0C\u5C0F\u4E8E\u7EC4\u4EF6\u6700\u5C0F\u9AD8\u5EA6\uFF01 diff --git a/designer_base/src/com/fr/design/locale/designer_zh_TW.properties b/designer_base/src/com/fr/design/locale/designer_zh_TW.properties index df75494c6b..dc9916ab18 100644 --- a/designer_base/src/com/fr/design/locale/designer_zh_TW.properties +++ b/designer_base/src/com/fr/design/locale/designer_zh_TW.properties @@ -579,4 +579,5 @@ FR-Designer-Move_Tab_First=\u79FB\u52D5\u5230\u9996\u4F4D FR-Designer-Move_Tab_End=\u79FB\u52D5\u5230\u672B\u5C3E FR-Designer-Move_Tab_Next=\u5F80\u5F8C\u79FB\u52D5 FR-Designer-Move_Tab_Prev=\u5F80\u524D\u79FB\u52D5 - +FR-Designer_Too_Large_To_Paste=\u7D44\u4EF6\u5927\u5C0F\u8D85\u51FA\u908A\u754C\uFF0C\u7121\u6CD5\u7C98\u8CBC\uFF01 +FR-Designer_Too_Small_To_Paste=\u6B64\u8655\u7121\u6CD5\u7C98\u8CBC\uFF0C\u5C0F\u65BC\u7D44\u4EF6\u6700\u5C0F\u9AD8\u5EA6\uFF01 diff --git a/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java b/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java index b8a8e8ad19..603626e13d 100644 --- a/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java +++ b/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java @@ -283,7 +283,6 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter { } else if (isCrossPointArea(parentComp, x, y)) { //交叉区域插入组件时,根据具体位置进行上下或者左右或者相邻三个组件的位置大小插入 fixCrossPointArea(parentComp, child, x, y); - //TODO 尽量不要出现这种写法吧?if else条件要么互斥,要么多个if判断return,不要在一条if else语句里面return吧? return; } else if (isTrisectionArea(parentComp, x, y)) { // 在边界三等分区域,就不再和组件二等分了 @@ -320,17 +319,15 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter { int height = creator.getHeight(); int width = creator.getWidth(); if (x < 0) { - width += x; - x = 0; + x = container.getX(); } else if (x + creator.getWidth() > container.getWidth()) { - width = container.getWidth() - x; + x = container.getWidth() - width; } if (y < 0) { - height += y; - y = 0; + y = container.getY(); } else if (y + creator.getHeight() > container.getHeight()) { - height = container.getHeight() - y; + y = container.getHeight() - height; } creator.setBounds(x, y, width, height); diff --git a/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRBodyLayoutAdapter.java b/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRBodyLayoutAdapter.java index b3072667b2..75190ba3bf 100644 --- a/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRBodyLayoutAdapter.java +++ b/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRBodyLayoutAdapter.java @@ -640,11 +640,7 @@ public class FRBodyLayoutAdapter extends AbstractLayoutAdapter { * 又通过ComponentUtils.getRelativeBounds()方法获取到了绝对坐标, * 再次计算相对坐标,所以将y值重新变成绝对坐标。 * */ - if (currentCreator.getBackupParent().getLocation().y == WBorderLayout.DEFAULT_SIZE) { - y = y + WCardMainBorderLayout.TAB_HEIGHT + WBorderLayout.DEFAULT_SIZE; - } else { - y = y + WCardMainBorderLayout.TAB_HEIGHT; - } + y = y + WCardMainBorderLayout.TAB_HEIGHT + this.getParaEditorYOffset(); int tempX = x - rect.x; int tempY = y - rect.y; int containerX = container.getX(); @@ -675,6 +671,26 @@ public class FRBodyLayoutAdapter extends AbstractLayoutAdapter { return position; } + /** + * 获取因为参数面板导致的Y坐标偏移 + * + * @return 参数面板导致的Y坐标偏移 + */ + protected int getParaEditorYOffset() { + int offset = 0; + if (container.getParent() != null) { + Component components[] = container.getParent().getComponents(); + for (Component component : components) { + if (component instanceof XWParameterLayout) { + offset = component.getY() + component.getHeight(); + break; + } + } + } + return offset; + } + + /** * 组件交叉区域进行插入时,调整受到变动的其他组件,之前是交叉区域插入也按照三等分逻辑,后面测试中发现有bug,改为和bi一样的鼠标所在侧平分 * 默认左上角、右下角区域是垂直方向插入组件 diff --git a/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java b/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java index e31ee6a5d3..eca82e5022 100644 --- a/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java +++ b/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java @@ -133,7 +133,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter { isFindRelatedComps = false; //拖入组件判断时,先判断是否为交叉点区域,其次三等分区域,再次平分区域 Component comp = container.getComponentAt(x, y); - if (checkInterval(comp)) { + if (comp == null || checkInterval(comp)) { return false; } //如果当前处于边缘地带, 那么就把他贴到父容器上 diff --git a/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRTabFitLayoutAdapter.java b/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRTabFitLayoutAdapter.java index 352a3ba7a6..b1ca803c6b 100644 --- a/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRTabFitLayoutAdapter.java +++ b/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRTabFitLayoutAdapter.java @@ -7,11 +7,13 @@ package com.fr.design.designer.beans.adapters.layout; import com.fr.design.beans.GroupModel; import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XLayoutContainer; +import com.fr.design.designer.creator.XWParameterLayout; import com.fr.design.designer.creator.XWidgetCreator; import com.fr.design.designer.creator.cardlayout.XWCardLayout; import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout; import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; import com.fr.design.designer.properties.FRTabFitLayoutPropertiesGroupModel; +import com.fr.design.mainframe.widget.editors.ParameterEditor; import com.fr.design.utils.ComponentUtils; import com.fr.form.ui.LayoutBorderStyle; import com.fr.form.ui.container.WBorderLayout; @@ -82,16 +84,14 @@ public class FRTabFitLayoutAdapter extends FRFitLayoutAdapter { return true; } - // tab布局的纵坐标受到tab高度的影响,判断的上边界取得是里面XWTabFitLayout的上边界, - // 实际计算的时候的纵坐标用了外层的CardMainBorerLayout,需要将tab高度减掉 - //将y值变为相对坐标以实现获取到鼠标drop位置的控件 - //TODO 可以直接在这边将x,y都变成相对坐标,这样在后面判断拖进来的新控件放置方式的时候就不用再判断了 + // tab布局的纵坐标受到tab高度以及参数面板高度的影响,判断的上边界取得是里面XWTabFitLayout的上边界, + // 实际计算的时候的纵坐标用了外层的CardMainBorerLayout,需要将tab高度和参数面板高度减掉 + // 将y值变为相对坐标以实现获取到鼠标drop位置的控件 + // TODO 可以直接在这边将x,y都变成相对坐标,这样在后面判断拖进来的新控件放置方式的时候就不用再判断了 private int adjustY(int y, XWTabFitLayout tabLayout) { XWCardLayout cardLayout = (XWCardLayout) tabLayout.getBackupParent(); LayoutBorderStyle style = cardLayout.toData().getBorderStyle(); - if (container.getLocation().y == WBorderLayout.DEFAULT_SIZE) { - y = y - WBorderLayout.DEFAULT_SIZE; - } + y = y - this.getParaEditorYOffset(); if (ComparatorUtils.equals(style.getType(), LayoutBorderStyle.TITLE)) { y = y - WCardMainBorderLayout.TAB_HEIGHT; } @@ -101,4 +101,5 @@ public class FRTabFitLayoutAdapter extends FRFitLayoutAdapter { protected Rectangle getLayoutBound(XWCardMainBorderLayout mainLayout) { return ComponentUtils.getRelativeBounds(mainLayout); } + } \ No newline at end of file diff --git a/designer_form/src/com/fr/design/designer/beans/models/AddingModel.java b/designer_form/src/com/fr/design/designer/beans/models/AddingModel.java index 46798f4d9a..54033694d9 100644 --- a/designer_form/src/com/fr/design/designer/beans/models/AddingModel.java +++ b/designer_form/src/com/fr/design/designer/beans/models/AddingModel.java @@ -18,116 +18,124 @@ import com.fr.general.ComparatorUtils; */ public class AddingModel { - // 当前要添加的组件 - private XCreator creator; - // 记录当前鼠标的位置信息 - private int current_x; - private int current_y; - private boolean added; - - public AddingModel(FormDesigner designer, XCreator xCreator) { - String creatorName = getXCreatorName(designer, xCreator); - this.creator = xCreator; - instantiateCreator(designer, creatorName); - // 初始的时候隐藏该组件的图标 - current_x = -this.creator.getWidth(); - current_y = -this.creator.getHeight(); - } + // 当前要添加的组件 + private XCreator creator; + // 记录当前鼠标的位置信息 + private int currentX; + private int currentY; + private boolean added; + + public AddingModel(FormDesigner designer, XCreator xCreator) { + String creatorName = getXCreatorName(designer, xCreator); + this.creator = xCreator; + instantiateCreator(designer, creatorName); + // 初始的时候隐藏该组件的图标 + currentY = -this.creator.getWidth(); + currentX = -this.creator.getHeight(); + } /** * 待说明 - * @param designer 设计器 - * @param creatorName 组件名 + * + * @param designer 设计器 + * @param creatorName 组件名 */ - public void instantiateCreator(FormDesigner designer, String creatorName) { - creator.toData().setWidgetName(creatorName); - ComponentAdapter adapter = new CompositeComponentAdapter(designer, creator); - adapter.initialize(); - creator.addNotify(); - creator.putClientProperty(AdapterBus.CLIENT_PROPERTIES, adapter); - } - - public AddingModel(XCreator xCreator, int x, int y) { - this.creator = xCreator; - this.creator.backupCurrentSize(); - this.creator.backupParent(); - this.creator.setSize(xCreator.initEditorSize()); - current_x = x - (xCreator.getWidth() / 2); - current_y = y - (xCreator.getHeight() / 2); - } + public void instantiateCreator(FormDesigner designer, String creatorName) { + creator.toData().setWidgetName(creatorName); + ComponentAdapter adapter = new CompositeComponentAdapter(designer, creator); + adapter.initialize(); + creator.addNotify(); + creator.putClientProperty(AdapterBus.CLIENT_PROPERTIES, adapter); + } + + public AddingModel(XCreator xCreator, int x, int y) { + this.creator = xCreator; + this.creator.backupCurrentSize(); + this.creator.backupParent(); + this.creator.setSize(xCreator.initEditorSize()); + currentX = x - (xCreator.getWidth() / 2); + currentY = y - (xCreator.getHeight() / 2); + } /** * 隐藏当前组件的图标 */ - public void reset() { - current_x = -this.creator.getWidth(); - current_y = -this.creator.getHeight(); - } + public void reset() { + currentX = -this.creator.getWidth(); + currentY = -this.creator.getHeight(); + } - public String getXCreatorName(FormDesigner designer,XCreator x){ - String def= x.createDefaultName(); + public String getXCreatorName(FormDesigner designer, XCreator x) { + String def = x.createDefaultName(); if (x.acceptType(XWParameterLayout.class)) { return def; } - int i = 0; - while (designer.getTarget().isNameExist(def + i)) { - i++; - } - return def+i; - } - - public int getCurrentX() { - return current_x; - } - - public int getCurrentY() { - return current_y; - } + int i = 0; + while (designer.getTarget().isNameExist(def + i)) { + i++; + } + return def + i; + } + + public int getCurrentX() { + return currentX; + } + + public int getCurrentY() { + return currentY; + } /** * 移动组件图标到鼠标事件发生的位置 - * @param x 坐标 - * @param y 坐标 + * + * @param x 坐标 + * @param y 坐标 */ - public void moveTo(int x, int y) { - current_x = x - (this.creator.getWidth() / 2); - current_y = y - (this.creator.getHeight() / 2); - } + public void moveTo(int x, int y) { + currentX = x - (this.creator.getWidth() / 2); + currentY = y - (this.creator.getHeight() / 2); + } - public XCreator getXCreator() { - return this.creator; - } + public XCreator getXCreator() { + return this.creator; + } /** * 当前组件是否已经添加到某个容器中 - * @return 是返回true + * + * @return 是返回true */ - public boolean isCreatorAdded() { - return added; - } + public boolean isCreatorAdded() { + return added; + } /** * 加入容器 - * @param designer 设计器 - * @param container 容器 - * @param x 坐标 - * @param y 坐标 - * @return 成功返回true + * + * @param designer 设计器 + * @param container 容器 + * @param x 坐标 + * @param y 坐标 + * @return 成功返回true */ - public boolean add2Container(FormDesigner designer, XLayoutContainer container, int x, int y) { - //考虑不同布局嵌套的情况,获取顶层容器 - XLayoutContainer xLayoutContainer = container.getTopLayout(); - if(xLayoutContainer != null && xLayoutContainer.acceptType(XWAbsoluteLayout.class)){ - container = xLayoutContainer; - } - - Rectangle rect = ComponentUtils.getRelativeBounds(container); - if(!ComparatorUtils.equals(container.getOuterLayout(), container.getBackupParent())){ - return added = container.getLayoutAdapter().addBean(creator, x + designer.getArea().getHorizontalValue(), y + designer.getArea().getVerticalValue()); - } - return added = container.getLayoutAdapter().addBean(creator, - x + designer.getArea().getHorizontalValue() - rect.x, - y + designer.getArea().getVerticalValue() - rect.y); - } + public boolean add2Container(FormDesigner designer, XLayoutContainer container, int x, int y) { + //考虑不同布局嵌套的情况,获取顶层容器 + XLayoutContainer xLayoutContainer = container.getTopLayout(); + if (xLayoutContainer != null && xLayoutContainer.acceptType(XWAbsoluteLayout.class)) { + container = xLayoutContainer; + } + + Rectangle rect = ComponentUtils.getRelativeBounds(container); + if (!ComparatorUtils.equals(container.getOuterLayout(), container.getBackupParent())) { + added = container.getLayoutAdapter().addBean(creator, + x + designer.getArea().getHorizontalValue(), + y + designer.getArea().getVerticalValue()); + return added; + } + added = container.getLayoutAdapter().addBean(creator, + x + designer.getArea().getHorizontalValue() - rect.x, + y + designer.getArea().getVerticalValue() - rect.y); + return added; + } } \ No newline at end of file diff --git a/designer_form/src/com/fr/design/designer/beans/models/SelectionModel.java b/designer_form/src/com/fr/design/designer/beans/models/SelectionModel.java index c364317f1a..a70d9b1566 100644 --- a/designer_form/src/com/fr/design/designer/beans/models/SelectionModel.java +++ b/designer_form/src/com/fr/design/designer/beans/models/SelectionModel.java @@ -13,6 +13,7 @@ import com.fr.design.form.util.XCreatorConstants; import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormSelection; import com.fr.design.mainframe.FormSelectionUtils; +import com.fr.design.utils.ComponentUtils; import com.fr.design.utils.gui.LayoutUtils; import com.fr.stable.ArrayUtils; @@ -26,7 +27,7 @@ import java.util.ArrayList; public class SelectionModel { //被粘贴组件在所选组件位置处往下、往右各错开20像素。执行多次粘贴时,在上一次粘贴的位置处错开20像素。 private static final int DELTA_X_Y = 20; //粘贴时候的偏移距离 - private static final int BORDER_PROPORTION = 20; + private static final double OFFSET_RELATIVE = 0.80; private static FormSelection clipboard = new FormSelection(); private FormDesigner designer; private FormSelection selection; @@ -111,7 +112,7 @@ public class SelectionModel { */ public boolean pasteFromClipBoard() { if (!clipboard.isEmpty()) { - if (!hasSelectionComponent()) { + if (!hasSelectedPasteSource()) { //未选 unselectedPaste(); } else { @@ -140,14 +141,14 @@ public class SelectionModel { FormSelectionUtils.paste2Container(designer, (XLayoutContainer) selection.getSelectedCreator(), clipboard, rec.x + rec.width / 2, - rec.y + BORDER_PROPORTION); + rec.y + DELTA_X_Y); } else { Rectangle rec = selection.getRelativeBounds(); //自适应布局 FormSelectionUtils.paste2Container(designer, designer.getRootComponent(), clipboard, rec.x + rec.width / 2, - rec.y + BORDER_PROPORTION); + rec.y + DELTA_X_Y); } } else { //绝对布局 @@ -172,18 +173,22 @@ public class SelectionModel { * 粘贴时选择组件 */ private void selectedPaste() { - XLayoutContainer parent = null; + XLayoutContainer container = null; //获取到编辑器的表层容器(已选的组件的父容器就是表层容器) - parent = XCreatorUtils.getParentXLayoutContainer(selection.getSelectedCreator()); - if (parent != null && selection.getSelectedCreator().getParent() instanceof XWFitLayout) { + container = XCreatorUtils.getParentXLayoutContainer(selection.getSelectedCreator()); + if (container != null && selection.getSelectedCreator().getParent() instanceof XWFitLayout) { //自适应布局 - Rectangle rec = selection.getRelativeBounds(); - FormSelectionUtils.paste2Container(designer, parent, clipboard, rec.x + rec.width / 2, rec.y + - rec.height - BORDER_PROPORTION); - } else if (parent != null && selection.getSelectedCreator().getParent() instanceof XWAbsoluteLayout) { + Rectangle selectionRec = selection.getRelativeBounds(); + Rectangle containerRec = ComponentUtils.getRelativeBounds(container); + //计算自适应布局位置 + int positionX = selectionRec.x - containerRec.x + selectionRec.width / 2; + int positionY = (int) (selectionRec.y - containerRec.y + selectionRec.height * OFFSET_RELATIVE); + + FormSelectionUtils.paste2Container(designer, container, clipboard, positionX, positionY); + } else if (container != null && selection.getSelectedCreator().getParent() instanceof XWAbsoluteLayout) { //绝对布局 Rectangle rec = selection.getSelctionBounds(); - FormSelectionUtils.paste2Container(designer, parent, clipboard, rec.x + DELTA_X_Y, rec.y + DELTA_X_Y); + FormSelectionUtils.paste2Container(designer, container, clipboard, rec.x + DELTA_X_Y, rec.y + DELTA_X_Y); } } @@ -198,13 +203,13 @@ public class SelectionModel { if (creator.acceptType(XWParameterLayout.class)) { designer.removeParaComponent(); } - removeCreatorFromContainer(creator, creator.getWidth(), creator.getHeight()); creator.removeAll(); // 清除被选中的组件 selection.reset(); } setSelectedCreator(designer.getRootComponent()); + FormSelectionUtils.rebuildSelection(designer); // 触发事件 designer.getEditListenerTable().fireCreatorModified(DesignerEvent.CREATOR_DELETED); designer.repaint(); @@ -275,7 +280,7 @@ public class SelectionModel { * 但是编辑窗口的最外层其实是表层@see {@link com.fr.design.designer.creator.XWAbsoluteBodyLayout}, * 其他两层不是靠添加组件就可以编辑的。 */ - public boolean hasSelectionComponent() { + public boolean hasSelectedPasteSource() { XCreator selectionXCreator = selection.getSelectedCreator(); if (designer.getClass().equals(FormDesigner.class)) { //frm本地组件复用 @@ -286,10 +291,12 @@ public class SelectionModel { || selectionXCreator.getClass().equals(XWTabFitLayout.class); //选中的是否是frm绝对布局编辑器本身 boolean absoluteEditor = selectionXCreator.getClass().equals(XWAbsoluteBodyLayout.class); + //选中是否是frm绝对画布块编辑器本身 + boolean absoluteCanvas = selectionXCreator.getClass().equals(XWAbsoluteLayout.class); //选中的是否是相对布局编辑器本身 boolean relativeEditor = selectionXCreator.getClass().equals(XWFitLayout.class); - return !(tabEditor || absoluteEditor || relativeEditor); + return !(tabEditor || absoluteEditor || absoluteCanvas || relativeEditor); } else { return false; } @@ -299,6 +306,15 @@ public class SelectionModel { } } + /** + * 是否有组件被选择。如果所选组件是最底层容器,也视为无选择 + * + * @return 是则返回true + */ + public boolean hasSelectionComponent() { + return !selection.isEmpty() && selection.getSelectedCreator().getParent() != null; + } + /** * 移动组件至指定位置 * diff --git a/designer_form/src/com/fr/design/designer/beans/models/StateModel.java b/designer_form/src/com/fr/design/designer/beans/models/StateModel.java index a623caddcf..f3aeb8f901 100644 --- a/designer_form/src/com/fr/design/designer/beans/models/StateModel.java +++ b/designer_form/src/com/fr/design/designer/beans/models/StateModel.java @@ -1,446 +1,476 @@ package com.fr.design.designer.beans.models; -import java.awt.Component; -import java.awt.Cursor; -import java.awt.Graphics; -import java.awt.Point; -import java.awt.Rectangle; -import java.awt.Toolkit; -import java.awt.event.MouseEvent; -import java.util.ArrayList; - import com.fr.design.beans.location.Absorptionline; -import com.fr.design.mainframe.FormDesigner; -import com.fr.design.mainframe.FormSelectionUtils; import com.fr.design.designer.beans.AdapterBus; import com.fr.design.designer.beans.HoverPainter; import com.fr.design.designer.beans.LayoutAdapter; import com.fr.design.designer.beans.events.DesignerEvent; import com.fr.design.designer.beans.location.Direction; import com.fr.design.designer.beans.location.Location; -import com.fr.design.designer.creator.XConnector; -import com.fr.design.designer.creator.XCreator; -import com.fr.design.designer.creator.XCreatorUtils; -import com.fr.design.designer.creator.XLayoutContainer; -import com.fr.design.designer.creator.XWAbsoluteLayout; +import com.fr.design.designer.creator.*; +import com.fr.design.mainframe.FormDesigner; +import com.fr.design.mainframe.FormSelectionUtils; import com.fr.design.utils.ComponentUtils; +import java.awt.*; +import java.awt.event.MouseEvent; +import java.util.ArrayList; + /** * 普通模式下的状态model */ public class StateModel { - // 对应的selection model - - private SelectionModel selectionModel; - // 当前鼠标进入拖拽区域的位置类型 - private Direction driection; - - // 当前拖拽的起始位置 - private int current_x; - private int current_y; - - private Point startPoint = new Point(); - private Point currentPoint = new Point(); - - private Absorptionline lineInX; - private Absorptionline lineInY; - //等距线 - private Absorptionline lineEquidistant; - - // 当前是否处于拖拽选择状态 - private boolean selecting; - private boolean dragging; - - private boolean addable; - - private FormDesigner designer; - - public StateModel(FormDesigner designer) { - this.designer = designer; - selectionModel = designer.getSelectionModel(); - } - - /** - * 返回direction - * @return direction方向 - */ - public Direction getDirection() { - return driection; - } - - /** - * 是否有组件正被选中 - * - * @return true 如果至少一个组件被选中 - */ - public boolean isSelecting() { - return selecting; - } + // 对应的selection model + + private SelectionModel selectionModel; + // 当前鼠标进入拖拽区域的位置类型 + private Direction driection; + + // 当前拖拽的起始位置 + private int currentX; + private int currentY; + + //拖拽组件原始位置大小备份 + private Rectangle selectedPositionBackup; + + private Point startPoint = new Point(); + private Point currentPoint = new Point(); + + private Absorptionline lineInX; + private Absorptionline lineInY; + //等距线 + private Absorptionline lineEquidistant; + + // 当前是否处于拖拽选择状态 + private boolean selecting; + private boolean dragging; + + private boolean addable; + + private FormDesigner designer; + + public StateModel(FormDesigner designer) { + this.designer = designer; + selectionModel = designer.getSelectionModel(); + } /** - *是否能拖拽 + * 返回direction + * + * @return direction方向 + */ + public Direction getDirection() { + return driection; + } + + /** + * 是否有组件正被选中 + * + * @return true 如果至少一个组件被选中 + */ + public boolean isSelecting() { + return selecting; + } + + /** + * 是否能拖拽 + * * @return 非outer且选中为空 */ - public boolean dragable() { - return ((driection != Location.outer) && !selecting); - } - - /** - * 拖拽中是否可以转换为添加模式: - * 如果拖拽组件只有一个,鼠标当前所在位置的最底层表单容器与这个组件的容器不同; - * 如果拖拽组件为多个,鼠标当前所在位置的最底层表单容器除了要求要跟这些组件的容器不同外,还必须是绝对定位布局 - */ - private void checkAddable(MouseEvent e) { - addable = false; - designer.setPainter(null); - - if (driection != Location.inner) { - return; - } - - XCreator comp = designer.getComponentAt(e.getX(), e.getY(), selectionModel.getSelection().getSelectedCreators()); - XLayoutContainer container = XCreatorUtils.getHotspotContainer(comp); - XCreator creator = selectionModel.getSelection().getSelectedCreator(); - Component creatorContainer = XCreatorUtils.getParentXLayoutContainer(creator); - if (creatorContainer != null && creatorContainer != container - && (selectionModel.getSelection().size() == 1 || container instanceof XWAbsoluteLayout)) { - HoverPainter painter = AdapterBus.getContainerPainter(designer, container); - designer.setPainter(painter); - if (painter != null) { - Rectangle rect = ComponentUtils.getRelativeBounds(container); - rect.x -= designer.getArea().getHorizontalValue(); - rect.y -= designer.getArea().getVerticalValue(); - painter.setRenderingBounds(rect); - painter.setHotspot(new Point(e.getX(), e.getY())); - painter.setCreator(creator); - } - addable = true; - } - } - - private boolean addBean(XLayoutContainer container, int x, int y) { - LayoutAdapter adapter = container.getLayoutAdapter(); - Rectangle r = ComponentUtils.getRelativeBounds(container); - if (selectionModel.getSelection().size() == 1) { - return adapter.addBean(selectionModel.getSelection().getSelectedCreator(), x - + designer.getArea().getHorizontalValue() - r.x, y + designer.getArea().getVerticalValue() - r.y); - } - for (XCreator creator : selectionModel.getSelection().getSelectedCreators()) { - adapter.addBean(creator, x + designer.getArea().getHorizontalValue() - r.x, y + designer.getArea().getVerticalValue()- r.y); - } - return true; - } - - private void adding(int x, int y) { + public boolean dragable() { + return ((driection != Location.outer) && !selecting); + } + + /** + * 拖拽中是否可以转换为添加模式: + * 如果拖拽组件只有一个,鼠标当前所在位置的最底层表单容器与这个组件的容器不同; + * 如果拖拽组件为多个,鼠标当前所在位置的最底层表单容器除了要求要跟这些组件的容器不同外,还必须是绝对定位布局 + */ + private void checkAddable(MouseEvent e) { + addable = false; + designer.setPainter(null); + + if (driection != Location.inner) { + return; + } + + XCreator comp = designer.getComponentAt(e.getX(), e.getY(), selectionModel.getSelection().getSelectedCreators()); + XLayoutContainer container = XCreatorUtils.getHotspotContainer(comp); + XCreator creator = selectionModel.getSelection().getSelectedCreator(); + Component creatorContainer = XCreatorUtils.getParentXLayoutContainer(creator); + if (creatorContainer != null && creatorContainer != container + && (selectionModel.getSelection().size() == 1 || container instanceof XWAbsoluteLayout)) { + HoverPainter painter = AdapterBus.getContainerPainter(designer, container); + designer.setPainter(painter); + if (painter != null) { + Rectangle rect = ComponentUtils.getRelativeBounds(container); + rect.x -= designer.getArea().getHorizontalValue(); + rect.y -= designer.getArea().getVerticalValue(); + painter.setRenderingBounds(rect); + painter.setHotspot(new Point(e.getX(), e.getY())); + painter.setCreator(creator); + } + addable = true; + } + } + + /** + * @param container 容器 + * @param mouseX 鼠标释放位置X + * @param mouseY 鼠标释放位置Y + * @return 是否成功 + */ + private boolean addBean(XLayoutContainer container, int mouseX, int mouseY) { + LayoutAdapter adapter = container.getLayoutAdapter(); + Rectangle rectangleContainer = ComponentUtils.getRelativeBounds(container); + if (selectionModel.getSelection().size() == 1) { + return adapter.addBean(selectionModel.getSelection().getSelectedCreator(), + mouseX + designer.getArea().getHorizontalValue() - rectangleContainer.x, + mouseY + designer.getArea().getVerticalValue() - rectangleContainer.y); + } + for (XCreator creator : selectionModel.getSelection().getSelectedCreators()) { + adapter.addBean(creator, + mouseX + designer.getArea().getHorizontalValue() - rectangleContainer.x, + mouseY + designer.getArea().getVerticalValue() - rectangleContainer.y); + } + return true; + } + + /** + * @param mouseReleasedX 鼠标释放位置X + * @param mouseReleasedY 鼠标释放位置Y + */ + private void adding(int mouseReleasedX, int mouseReleasedY) { // 当前鼠标所在的组件 - XCreator hoveredComponent = designer.getComponentAt(x, y, selectionModel.getSelection().getSelectedCreators()); + XCreator hoveredComponent = designer.getComponentAt(mouseReleasedX, mouseReleasedY, selectionModel.getSelection().getSelectedCreators()); // 获取该组件所在的焦点容器 XLayoutContainer container = XCreatorUtils.getHotspotContainer(hoveredComponent); boolean success = false; - if (container != null) { - // 如果是容器,则调用其acceptComponent接受组件 - success = addBean(container, x, y); - } - - if (success) { - FormSelectionUtils.rebuildSelection(designer); - designer.getEditListenerTable().fireCreatorModified( - selectionModel.getSelection().getSelectedCreator(), DesignerEvent.CREATOR_ADDED); - } else { - Toolkit.getDefaultToolkit().beep(); - } - + if (container != null) { + // 如果是容器,则调用其acceptComponent接受组件 + success = addBean(container, mouseReleasedX, mouseReleasedY); + } + + if (success) { + FormSelectionUtils.rebuildSelection(designer); + designer.getEditListenerTable().fireCreatorModified( + selectionModel.getSelection().getSelectedCreator(), DesignerEvent.CREATOR_ADDED); + } else { + selectionModel.getSelection().setSelectionBounds(selectedPositionBackup, designer); + Toolkit.getDefaultToolkit().beep(); + } // 取消提示 designer.setPainter(null); } /** - *是否拖拽 + * 是否拖拽 + * * @return dragging状态 */ - public boolean isDragging() { - return dragging; - } + public boolean isDragging() { + return dragging; + } /** - *是否可以开始画线 + * 是否可以开始画线 + * * @return startPoint不为空返回true */ - public boolean prepareForDrawLining() { - return startPoint != null; - } + public boolean prepareForDrawLining() { + return startPoint != null; + } /** - *设置开始位置 + * 设置开始位置 + * * @param p point位置 */ - public void setStartPoint(Point p) { - this.startPoint = p; - } + public void setStartPoint(Point p) { + this.startPoint = p; + } /** - *返回开始位置 + * 返回开始位置 + * * @return 点位置 */ - public Point getStartPoint() { - return startPoint; - } + public Point getStartPoint() { + return startPoint; + } /** - *返回当前点位置 + * 返回当前点位置 + * * @return 点位置 */ public Point getEndPoint() { - return currentPoint; - } + return currentPoint; + } /** - *当前选中组件 + * 当前选中组件 + * * @param e 鼠标事件 */ - public void startSelecting(MouseEvent e) { - selecting = true; - selectionModel.setHotspotBounds(new Rectangle()); - current_x = getMouseXY(e).x; - current_y = getMouseXY(e).y; - } + public void startSelecting(MouseEvent e) { + selecting = true; + selectionModel.setHotspotBounds(new Rectangle()); + currentX = getMouseXY(e).x; + currentY = getMouseXY(e).y; + } /** - *当前鼠标的xy + * 当前鼠标的xy + * * @param e 鼠标事件 */ - public void startResizing(MouseEvent e) { - if (!selectionModel.getSelection().isEmpty()) { - driection.backupBounds(designer); - } - current_x = getMouseXY(e).x; - current_y = getMouseXY(e).y; - } + public void startResizing(MouseEvent e) { + if (!selectionModel.getSelection().isEmpty()) { + driection.backupBounds(designer); + } + currentX = getMouseXY(e).x; + currentY = getMouseXY(e).y; + } /** - *起始点开始DrawLine + * 起始点开始DrawLine + * * @param p 点位置 */ - public void startDrawLine(Point p) { - this.startPoint = p; - if(p != null) { - try { - designer.setCursor(XConnector.connectorCursor); - } catch (Exception e) { - } - } else { - designer.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); - } - } + public void startDrawLine(Point p) { + this.startPoint = p; + if (p != null) { + try { + designer.setCursor(XConnector.connectorCursor); + } catch (Exception e) { + } + } else { + designer.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); + } + } /** - *鼠标释放时所在的区域及圈中的组件 + * 鼠标释放时所在的区域及圈中的组件 + * * @param e 鼠标事件 */ - public void selectCreators(MouseEvent e) { - int x = getMouseXY(e).x; - int y = getMouseXY(e).y; + public void selectCreators(MouseEvent e) { + int x = getMouseXY(e).x; + int y = getMouseXY(e).y; - Rectangle bounds = createCurrentBounds(x, y); + Rectangle bounds = createCurrentBounds(x, y); - if ((x != current_x) || (y != current_y)) { - selectionModel.setSelectedCreators(getHotspotCreators(bounds, designer.getRootComponent())); - } - selectionModel.setHotspotBounds(null); - } + if ((x != currentX) || (y != currentY)) { + selectionModel.setSelectedCreators(getHotspotCreators(bounds, designer.getRootComponent())); + } + selectionModel.setHotspotBounds(null); + } /** - *画所在区域线 + * 画所在区域线 + * * @param e 鼠标事件 */ - public void drawLine(MouseEvent e) { - designer.getDrawLineHelper().setDrawLine(true); - Point p = designer.getDrawLineHelper().getNearWidgetPoint(e); - if (p != null) { - currentPoint = p; - } else { - currentPoint.x = e.getX() + designer.getArea().getHorizontalValue(); - currentPoint.y = e.getY() + designer.getArea().getVerticalValue(); - } - } - - private Rectangle createCurrentBounds(int x, int y) { - Rectangle bounds = new Rectangle(); - - bounds.x = Math.min(x, current_x); - bounds.y = Math.min(y, current_y); - bounds.width = Math.max(x, current_x) - bounds.x; - bounds.height = Math.max(y, current_y) - bounds.y; - - return bounds; - } - - private ArrayList getHotspotCreators(Rectangle selection, XCreator root) { - ArrayList creators = new ArrayList(); - - if (!root.isVisible() && !designer.isRoot(root)) { - return creators; - } - - if (root instanceof XLayoutContainer) { - XLayoutContainer container = (XLayoutContainer) root; - int count = container.getXCreatorCount(); - Rectangle clipped = new Rectangle(selection); - - for (int i = count - 1; i >= 0; i--) { - XCreator child = container.getXCreator(i); - - if (selection.contains(child.getBounds())) { - creators.add(child); - } else { - clipped.x = selection.x - child.getX(); - clipped.y = selection.y - child.getY(); - creators.addAll(getHotspotCreators(clipped, child)); - } - } - } - - return creators; - } + public void drawLine(MouseEvent e) { + designer.getDrawLineHelper().setDrawLine(true); + Point p = designer.getDrawLineHelper().getNearWidgetPoint(e); + if (p != null) { + currentPoint = p; + } else { + currentPoint.x = e.getX() + designer.getArea().getHorizontalValue(); + currentPoint.y = e.getY() + designer.getArea().getVerticalValue(); + } + } + + private Rectangle createCurrentBounds(int x, int y) { + Rectangle bounds = new Rectangle(); + + bounds.x = Math.min(x, currentX); + bounds.y = Math.min(y, currentY); + bounds.width = Math.max(x, currentX) - bounds.x; + bounds.height = Math.max(y, currentY) - bounds.y; + + return bounds; + } + + private ArrayList getHotspotCreators(Rectangle selection, XCreator root) { + ArrayList creators = new ArrayList<>(); + + if (!root.isVisible() && !designer.isRoot(root)) { + return creators; + } + + if (root instanceof XLayoutContainer) { + XLayoutContainer container = (XLayoutContainer) root; + int count = container.getXCreatorCount(); + Rectangle clipped = new Rectangle(selection); + + for (int i = count - 1; i >= 0; i--) { + XCreator child = container.getXCreator(i); + + if (selection.contains(child.getBounds())) { + creators.add(child); + } else { + clipped.x = selection.x - child.getX(); + clipped.y = selection.y - child.getY(); + creators.addAll(getHotspotCreators(clipped, child)); + } + } + } + + return creators; + } /** - *重置model + * 重置model */ - public void resetModel() { - dragging = false; - selecting = false; - } + public void resetModel() { + dragging = false; + selecting = false; + } /** - *重置 + * 重置 */ - public void reset() { - driection = Location.outer; - dragging = false; - selecting = false; - } + public void reset() { + driection = Location.outer; + dragging = false; + selecting = false; + } /** - *取消拖拽 + * 取消拖拽 */ - public void draggingCancel() { - designer.repaint(); - reset(); - } + public void draggingCancel() { + designer.repaint(); + reset(); + } /** - *设置可拉伸方向 + * 设置可拉伸方向 + * * @param dir 拉伸方向 */ - public void setDirection(Direction dir) { - if(driection != dir) { - this.driection = dir; - driection.updateCursor(designer); - } - } + public void setDirection(Direction dir) { + if (driection != dir) { + this.driection = dir; + driection.updateCursor(designer); + } + } /** - *x吸附线赋值 + * x吸附线赋值 + * * @param line 线 */ - public void setXAbsorptionline(Absorptionline line) { - this.lineInX = line; - } + public void setXAbsorptionline(Absorptionline line) { + this.lineInX = line; + } /** - *y吸附线赋值 + * y吸附线赋值 + * + * @param line 线 + */ + public void setYAbsorptionline(Absorptionline line) { + this.lineInY = line; + } + + /** + * 等距线赋值 + * * @param line 线 */ - public void setYAbsorptionline(Absorptionline line) { - this.lineInY = line; - } - - /** - * 等距线赋值 - * @param line 线 - */ - public void setEquidistantLine(Absorptionline line){ - this.lineEquidistant = line; - } + public void setEquidistantLine(Absorptionline line) { + this.lineEquidistant = line; + } /** - *画吸附线 + * 画吸附线 + * * @param g Graphics类 */ - public void paintAbsorptionline(Graphics g) { - if(lineInX != null) { - lineInX.paint(g,designer.getArea()); - } - if(lineInY != null) { - lineInY.paint(g,designer.getArea()); - } - if(lineEquidistant != null){ - lineEquidistant.paint(g,designer.getArea()); - } - } + public void paintAbsorptionline(Graphics g) { + if (lineInX != null) { + lineInX.paint(g, designer.getArea()); + } + if (lineInY != null) { + lineInY.paint(g, designer.getArea()); + } + if (lineEquidistant != null) { + lineEquidistant.paint(g, designer.getArea()); + } + } /** - *拖拽 + * 拖拽 + * * @param e 鼠标事件 */ - public void dragging(MouseEvent e) { - checkAddable(e); - setDependLinePainter(e); - driection.drag(getMouseXY(e).x-current_x, getMouseXY(e).y-current_y, designer); - this.dragging = true; - } - - // 拖拽时画依附线用到的painter - private void setDependLinePainter(MouseEvent e){ - XCreator comp = designer.getComponentAt(e.getX(), e.getY(), selectionModel.getSelection().getSelectedCreators()); - XLayoutContainer container = XCreatorUtils.getHotspotContainer(comp); - XCreator creator = selectionModel.getSelection().getSelectedCreator(); - HoverPainter painter = AdapterBus.getContainerPainter(designer, container); - designer.setPainter(painter); - if (painter != null) { - painter.setHotspot(new Point(e.getX(), e.getY())); - painter.setCreator(creator); - } - } + public void dragging(MouseEvent e) { + //进入dragging状态时备份组件大小和位置 + if (!dragging) { + selectedPositionBackup = selectionModel.getSelection().getRelativeBounds(); + } + checkAddable(e); + setDependLinePainter(e); + driection.drag(getMouseXY(e).x - currentX, getMouseXY(e).y - currentY, designer); + this.dragging = true; + } + + // 拖拽时画依附线用到的painter + private void setDependLinePainter(MouseEvent e) { + XCreator comp = designer.getComponentAt(e.getX(), e.getY(), selectionModel.getSelection().getSelectedCreators()); + XLayoutContainer container = XCreatorUtils.getHotspotContainer(comp); + XCreator creator = selectionModel.getSelection().getSelectedCreator(); + HoverPainter painter = AdapterBus.getContainerPainter(designer, container); + designer.setPainter(painter); + if (painter != null) { + painter.setHotspot(new Point(e.getX(), e.getY())); + painter.setCreator(creator); + } + } /** - *释放捕获 + * 释放捕获 + * * @param e 鼠标事件 */ - public void releaseDragging(MouseEvent e) { - this.dragging = false; - if (addable) { - adding(e.getX(), e.getY()); - } else if (!selectionModel.getSelection().isEmpty()) { - selectionModel.releaseDragging(); - } - designer.repaint(); - } + public void releaseDragging(MouseEvent e) { + this.dragging = false; + if (addable) { + adding(e.getX(), e.getY()); + } else if (!selectionModel.getSelection().isEmpty()) { + selectionModel.releaseDragging(); + } + designer.repaint(); + } /** - *改变选择区域 + * 改变选择区域 * - * @param e 鼠标事件 + * @param e 鼠标事件 */ - public void changeSelection(MouseEvent e) { - Rectangle bounds = createCurrentBounds(getMouseXY(e).x, getMouseXY(e).y); - selectionModel.setHotspotBounds(bounds); - } + public void changeSelection(MouseEvent e) { + Rectangle bounds = createCurrentBounds(getMouseXY(e).x, getMouseXY(e).y); + selectionModel.setHotspotBounds(bounds); + } /** - *返回鼠标所在的x、y 考虑滚动条的值 + * 返回鼠标所在的x、y 考虑滚动条的值 * * @param e 鼠标事件 * @return xy值 */ - public Point getMouseXY(MouseEvent e) { - Point p1 = new Point(e.getX() + designer.getArea().getHorizontalValue(), e.getY() - + designer.getArea().getVerticalValue()); - return p1; - } - + public Point getMouseXY(MouseEvent e) { + Point p1 = new Point(e.getX() + designer.getArea().getHorizontalValue(), e.getY() + + designer.getArea().getVerticalValue()); + return p1; + } + } \ No newline at end of file diff --git a/designer_form/src/com/fr/design/designer/beans/painters/AbstractPainter.java b/designer_form/src/com/fr/design/designer/beans/painters/AbstractPainter.java index 06565fe4f3..cb5c6a4a0a 100644 --- a/designer_form/src/com/fr/design/designer/beans/painters/AbstractPainter.java +++ b/designer_form/src/com/fr/design/designer/beans/painters/AbstractPainter.java @@ -22,6 +22,7 @@ public abstract class AbstractPainter implements HoverPainter { /** * 构造函数 + * * @param container 容器 */ public AbstractPainter(XLayoutContainer container) { @@ -32,23 +33,25 @@ public abstract class AbstractPainter implements HoverPainter { public void setHotspot(Point p) { hotspot = p; } - + /** - * 画初始区域 - * @param g 画图类 - * @param startX 起始x位置 - * @param startY 起始y位置 + * 画初始区域 + * + * @param g 画图类 + * @param startX 起始x位置 + * @param startY 起始y位置 + */ + public void paint(Graphics g, int startX, int startY) { + if (hotspot_bounds != null) { + drawHotspot(g, hotspot_bounds.x, hotspot_bounds.y, hotspot_bounds.width, hotspot_bounds.height, Color.lightGray, true, false); + } + } + + /** + * 设置边界 + * + * @param rect 位置 */ - public void paint(Graphics g, int startX, int startY) { - if(hotspot_bounds != null){ - drawHotspot(g, hotspot_bounds.x, hotspot_bounds.y, hotspot_bounds.width, hotspot_bounds.height, Color.lightGray, true, false); - } - } - - /** - * 设置边界 - * @param rect 位置 - */ @Override public void setRenderingBounds(Rectangle rect) { hotspot_bounds = rect; @@ -63,12 +66,12 @@ public abstract class AbstractPainter implements HoverPainter { Color bColor = accept ? XCreatorConstants.LAYOUT_HOTSPOT_COLOR : XCreatorConstants.LAYOUT_FORBIDDEN_COLOR; drawHotspot(g, x, y, width, height, bColor, accept, false); } - + /** * 自适应布局那边渲染提示,要画整个背景,不是画边框 */ protected void drawRegionBackground(Graphics g, int x, int y, int width, int height, Color bColor, boolean accept) { - drawHotspot(g, x, y, width, height, bColor, accept, true); + drawHotspot(g, x, y, width, height, bColor, accept, true); } protected void drawHotspot(Graphics g, int x, int y, int width, int height, Color bColor, boolean accept, boolean drawBackground) { @@ -81,13 +84,13 @@ public abstract class AbstractPainter implements HoverPainter { if (!accept) { g2d.drawString(Inter.getLocText("Cannot-Add_To_This_Area") + "!", x + width / 3, y + height / 2); } else if (drawBackground) { - g2d.fillRect(x, y, width, height); + g2d.fillRect(x, y, width, height); } else { - g2d.drawRect(x, y, width, height); + g2d.drawRect(x, y, width, height); } g2d.setStroke(backup); g2d.setColor(color); } - - + + } \ No newline at end of file diff --git a/designer_form/src/com/fr/design/designer/creator/XLayoutContainer.java b/designer_form/src/com/fr/design/designer/creator/XLayoutContainer.java index 254e9a9184..edd1c69f0f 100644 --- a/designer_form/src/com/fr/design/designer/creator/XLayoutContainer.java +++ b/designer_form/src/com/fr/design/designer/creator/XLayoutContainer.java @@ -30,12 +30,12 @@ import java.util.List; * @since 6.5.3 */ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator implements ContainerListener, ParameterBridge { - - // 布局内部组件默认最小宽度36,最小高度21 - public static int MIN_WIDTH = 36; - public static int MIN_HEIGHT = 21; - - protected static final Dimension LARGEPREFERREDSIZE = new Dimension(200, 200); + + // 布局内部组件默认最小宽度36,最小高度21 + public static int MIN_WIDTH = 36; + public static int MIN_HEIGHT = 21; + + protected static final Dimension LARGEPREFERREDSIZE = new Dimension(200, 200); protected boolean isRefreshing; protected int default_Length = 5; // 取指定点坐在的组件,默认为5保证取四侧相邻的组件时x、y在组件内非边框上 @@ -45,6 +45,7 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme protected boolean editable = false; //鼠标移动到布局画出编辑层 protected boolean isMouseEnter = false; + public void setMouseEnter(boolean mouseEnter) { isMouseEnter = mouseEnter; } @@ -55,12 +56,13 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme } /** - * 得到属性名 + * 得到属性名 + * * @return 属性名 * @throws IntrospectionException */ - public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { - return new CRPropertyDescriptor[] { + public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { + return new CRPropertyDescriptor[]{ new CRPropertyDescriptor("widgetName", this.data.getClass()).setI18NName(Inter .getLocText("FR-Designer_Form-Widget_Name")), new CRPropertyDescriptor("borderStyle", this.data.getClass()).setEditorClass( @@ -68,19 +70,20 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme Inter.getLocText("FR-Engine_Style")).putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced") .setPropertyChangeListener(new PropertyChangeAdapter() { - @Override - public void propertyChange() { - initStyle(); - } - }), + @Override + public void propertyChange() { + initStyle(); + } + }), new CRPropertyDescriptor("margin", this.data.getClass()).setEditorClass(PaddingMarginEditor.class) .setI18NName(Inter.getLocText("FR-Designer_Layout-Padding")) .putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced"), - }; - } + }; + } /** * 控件名属性 + * * @return * @throws IntrospectionException */ @@ -91,6 +94,7 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme /** * 边距属性 + * * @return * @throws IntrospectionException */ @@ -101,47 +105,50 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme } /** - * 返回对应的wlayout + * 返回对应的wlayout + * * @return wlayout控件 */ public WLayout toData() { return (WLayout) data; } - @Override - protected void initXCreatorProperties() { - super.initXCreatorProperties(); - initBorderStyle(); - this.initLayoutManager(); - this.convert(); - } + @Override + protected void initXCreatorProperties() { + super.initXCreatorProperties(); + initBorderStyle(); + this.initLayoutManager(); + this.convert(); + } @Override - protected JComponent initEditor() { - return this; - } - - /** - * 当前组件zorder位置替换新的控件 - * @param widget 控件 - * @param oldcreator 旧组件 - * @return 组件 - */ - public XCreator replace(Widget widget, XCreator oldcreator) { - int i = this.getComponentZOrder(oldcreator); - if (i != -1) { - this.toData().replace(widget, oldcreator.toData()); - this.convert(); - XCreator creator = (XCreator) this.getComponent(i); - creator.setSize(oldcreator.getSize()); - return creator; - } - return null; - } - - /** - * 初始化时默认的组件大小 - * @return 默认Dimension + protected JComponent initEditor() { + return this; + } + + /** + * 当前组件zorder位置替换新的控件 + * + * @param widget 控件 + * @param oldcreator 旧组件 + * @return 组件 + */ + public XCreator replace(Widget widget, XCreator oldcreator) { + int i = this.getComponentZOrder(oldcreator); + if (i != -1) { + this.toData().replace(widget, oldcreator.toData()); + this.convert(); + XCreator creator = (XCreator) this.getComponent(i); + creator.setSize(oldcreator.getSize()); + return creator; + } + return null; + } + + /** + * 初始化时默认的组件大小 + * + * @return 默认Dimension */ public Dimension initEditorSize() { return LARGEPREFERREDSIZE; @@ -172,7 +179,8 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme /** * 设计界面中有组件添加时,要通知WLayout容器重新paint - * @param e 待说明 + * + * @param e 待说明 */ @Override public void componentAdded(ContainerEvent e) { @@ -188,7 +196,8 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme /** * 设计界面中有组件添加时,要通知WLayout容器重新paint - * @param e 待说明 + * + * @param e 待说明 */ @Override public void componentRemoved(ContainerEvent e) { @@ -203,6 +212,7 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme /** * 根据widget的属性值来获取 + * * @param wgt * @return */ @@ -226,30 +236,32 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme public int getXCreatorCount() { return getComponentCount(); } - + public XCreator getXCreator(int i) { return (XCreator) getComponent(i); } /** * 该组件是否可以拖入参数面板 + * * @return 是则返回true */ - public boolean canEnterIntoParaPane(){ + public boolean canEnterIntoParaPane() { return false; } - + /** - * 是否作为控件树的叶子节点 - * @return 是则返回true - */ - public boolean isComponentTreeLeaf() { - return false; - } + * 是否作为控件树的叶子节点 + * + * @return 是则返回true + */ + public boolean isComponentTreeLeaf() { + return false; + } - public List getAllXCreatorNameList(XCreator xCreator, List namelist){ - for (int i = 0; i < ((XLayoutContainer)xCreator).getXCreatorCount(); i++) { - XCreator creatorSon = ((XLayoutContainer)xCreator).getXCreator(i); + public List getAllXCreatorNameList(XCreator xCreator, List namelist) { + for (int i = 0; i < ((XLayoutContainer) xCreator).getXCreatorCount(); i++) { + XCreator creatorSon = ((XLayoutContainer) xCreator).getXCreator(i); creatorSon.getAllXCreatorNameList(creatorSon, namelist); } return namelist; @@ -257,19 +269,20 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme /** * 是否有查询按钮 - * @param xCreator 控件或容器 - * @return 有无查询按钮 + * + * @param xCreator 控件或容器 + * @return 有无查询按钮 */ public boolean SearchQueryCreators(XCreator xCreator) { - for (int i = 0; i < ((XLayoutContainer)xCreator).getXCreatorCount(); i++) { - XCreator creatorSon = ((XLayoutContainer)xCreator).getXCreator(i); - if(creatorSon.SearchQueryCreators(creatorSon)){ + for (int i = 0; i < ((XLayoutContainer) xCreator).getXCreatorCount(); i++) { + XCreator creatorSon = ((XLayoutContainer) xCreator).getXCreator(i); + if (creatorSon.SearchQueryCreators(creatorSon)) { return true; } } return false; } - + public FRLayoutManager getFRLayout() { LayoutManager layout = getLayout(); if (layout instanceof FRLayoutManager) { @@ -279,111 +292,120 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme return null; } - public abstract LayoutAdapter getLayoutAdapter(); - - public int getIndexOfChild(Object child) { - int count = getComponentCount(); - for (int i = 0; i < count; i++) { - Component comp = getComponent(i); - if (comp == child) { - return i; - } - } - return -1; - } - - /** - * 主要为自适应用 - * 返回指定point的上方组件 - * @param x x位置 - * @param y y位置 - * @return 指定位置的组件 - */ - public Component getTopComp(int x, int y) { - return this.getComponentAt(x, y-default_Length); - } - - /** - * 主要为自适应用 - * 返回指定point的左方组件 - * @param x x位置 - * @param y y位置 - * @return 指定位置的组件 - */ - public Component getLeftComp(int x, int y) { - return this.getComponentAt(x-default_Length, y); - } - - /** - * 返回指定point的右方组件 - * @param x x位置 - * @param y y位置 - * @param w 宽度 - * @return 指定位置的组件 - */ - public Component getRightComp(int x, int y, int w) { - return this.getComponentAt(x+w+default_Length, y); - } - - /** - * 返回指定point的下方组件 - * @param x x位置 - * @param y y位置 - * @param h 高度 - * @return 指定位置的组件 - */ - public Component getBottomComp(int x, int y, int h) { - return this.getComponentAt(x, y+h+default_Length); - } - - /** - * 返回指定point的上方且是右侧的组件 - * @param x x位置 - * @param y y位置 - * @param w 宽度 - * @return 指定位置的组件 - */ - public Component getRightTopComp(int x, int y, int w) { - return this.getComponentAt(x+w-default_Length, y-default_Length); - } - - /** - * 返回指定point的左方且是下侧的组件 - * @param x x位置 - * @param y y位置 - * @param h 高度 - * @return 指定位置的组件 - */ - public Component getBottomLeftComp(int x, int y, int h) { - return this.getComponentAt(x-default_Length, y+h-default_Length); - } - - /** - * 返回指定point的右方且是下侧的组件 - * @param x x位置 - * @param y y位置 - * @param h 高度 - * @param w 宽度 - * @return 指定位置的组件 - */ - public Component getBottomRightComp(int x, int y, int h, int w) { - return this.getComponentAt(x+w+default_Length, y+h-default_Length); - } - - /** - * 返回指定point的下方且是右侧的组件 - * @param x x位置 - * @param y y位置 - * @param h 高度 - * @param w 宽度 - * @return 指定位置的组件 - */ - public Component getRightBottomComp(int x, int y, int h, int w) { - return this.getComponentAt(x+w-default_Length, y+h+default_Length); - } + public abstract LayoutAdapter getLayoutAdapter(); + + public int getIndexOfChild(Object child) { + int count = getComponentCount(); + for (int i = 0; i < count; i++) { + Component comp = getComponent(i); + if (comp == child) { + return i; + } + } + return -1; + } + + /** + * 主要为自适应用 + * 返回指定point的上方组件 + * + * @param x x位置 + * @param y y位置 + * @return 指定位置的组件 + */ + public Component getTopComp(int x, int y) { + return this.getComponentAt(x, y - default_Length); + } + + /** + * 主要为自适应用 + * 返回指定point的左方组件 + * + * @param x x位置 + * @param y y位置 + * @return 指定位置的组件 + */ + public Component getLeftComp(int x, int y) { + return this.getComponentAt(x - default_Length, y); + } + + /** + * 返回指定point的右方组件 + * + * @param x x位置 + * @param y y位置 + * @param w 宽度 + * @return 指定位置的组件 + */ + public Component getRightComp(int x, int y, int w) { + return this.getComponentAt(x + w + default_Length, y); + } + + /** + * 返回指定point的下方组件 + * + * @param x x位置 + * @param y y位置 + * @param h 高度 + * @return 指定位置的组件 + */ + public Component getBottomComp(int x, int y, int h) { + return this.getComponentAt(x, y + h + default_Length); + } + + /** + * 返回指定point的上方且是右侧的组件 + * + * @param x x位置 + * @param y y位置 + * @param w 宽度 + * @return 指定位置的组件 + */ + public Component getRightTopComp(int x, int y, int w) { + return this.getComponentAt(x + w - default_Length, y - default_Length); + } + + /** + * 返回指定point的左方且是下侧的组件 + * + * @param x x位置 + * @param y y位置 + * @param h 高度 + * @return 指定位置的组件 + */ + public Component getBottomLeftComp(int x, int y, int h) { + return this.getComponentAt(x - default_Length, y + h - default_Length); + } + + /** + * 返回指定point的右方且是下侧的组件 + * + * @param x x位置 + * @param y y位置 + * @param h 高度 + * @param w 宽度 + * @return 指定位置的组件 + */ + public Component getBottomRightComp(int x, int y, int h, int w) { + return this.getComponentAt(x + w + default_Length, y + h - default_Length); + } + + /** + * 返回指定point的下方且是右侧的组件 + * + * @param x x位置 + * @param y y位置 + * @param h 高度 + * @param w 宽度 + * @return 指定位置的组件 + */ + public Component getRightBottomComp(int x, int y, int h, int w) { + return this.getComponentAt(x + w - default_Length, y + h + default_Length); + } /** * 是否延迟展示报表内容,也就是说是否要等点击了查询之后才执行报表 + * * @return 如果是true,则表示点击之后才开始计算,false则表示会根据参数默认值直接计算报表并展现 */ public boolean isDelayDisplayContent() { @@ -392,18 +414,20 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme /** * 是否显示参数界面 + * * @return 显示参数界面则返回true,否则返回false */ public boolean isDisplay() { return false; } - public Background getDataBackground(){ + public Background getDataBackground() { return toData().getBackground(); } /** * 获取参数界面的宽度 + * * @return 宽度 */ public int getDesignWidth() { @@ -412,83 +436,82 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme /** * 获取参数面板的对齐方式 + * * @return 左中右三种对齐方式 */ public int getPosition() { return 0; } - + /** * 切换到非添加状态 - * + * * @param designer 表单设计器 */ - public void stopAddingState(FormDesigner designer){ - return; - } - - /** - * 寻找最近的为自适应布局的父容器 - * - * @return 布局容器 - * - * - * @date 2014-12-30-下午3:15:28 - * - */ - public XLayoutContainer findNearestFit(){ - //一层一层网上找, 找到最近的fit那一层就return - XLayoutContainer parent = this.getBackupParent(); - return parent == null ? null : parent.findNearestFit(); - } - + public void stopAddingState(FormDesigner designer) { + } + + /** + * 寻找最近的为自适应布局的父容器 + * + * @return 布局容器 + * @date 2014-12-30-下午3:15:28 + */ + public XLayoutContainer findNearestFit() { + //一层一层网上找, 找到最近的fit那一层就return + XLayoutContainer parent = this.getBackupParent(); + return parent == null ? null : parent.findNearestFit(); + } + /** * 获取容器所有内部组件横坐标值 - * + * * @return 横坐标数组 */ - public int[] getHors(){ - return ArrayUtils.EMPTY_INT_ARRAY; + public int[] getHors() { + return ArrayUtils.EMPTY_INT_ARRAY; } - + /** * 获取容器所有内部组件纵坐标值 - * + * * @return 纵坐标数组 */ - public int[] getVeris(){ - return ArrayUtils.EMPTY_INT_ARRAY; + public int[] getVeris() { + return ArrayUtils.EMPTY_INT_ARRAY; } - public void setDelayDisplayContent(boolean delayPlaying){ + public void setDelayDisplayContent(boolean delayPlaying) { } - public void setPosition(int align){ + public void setPosition(int align) { } - public void setDisplay(boolean showWindow){ + public void setDisplay(boolean showWindow) { } - public void setBackground(Background background){ + public void setBackground(Background background) { } /** * 布局是否可编辑,不可则显示编辑蒙层 + * * @return 可否编辑 */ - public boolean isEditable(){ + public boolean isEditable() { return this.editable; } /** * 设置布局是否可编辑,不可则显示编辑蒙层 + * * @param isEditable 可否编辑 */ - public void setEditable(boolean isEditable){ + public void setEditable(boolean isEditable) { this.editable = isEditable; } } \ No newline at end of file diff --git a/designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java b/designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java index 947ec5eaba..114ce3240c 100644 --- a/designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java +++ b/designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java @@ -1,5 +1,5 @@ /** - * + * */ package com.fr.design.designer.creator.cardlayout; @@ -25,114 +25,109 @@ import com.fr.form.ui.container.cardlayout.WCardTagLayout; import com.fr.form.ui.container.cardlayout.WTabFitLayout; /** - * - * * @date: 2014-11-25-下午3:11:14 */ public class XWCardTagLayout extends XWHorizontalBoxLayout { - - private static final int MIN_SIZE = 1; - - private String tagName = "Tab"; - - private boolean switchingTab = false; - - //增加一个tabNameIndex防止tabFitLayout重名 - private int tabFitIndex = 0; - private CardSwitchButton currentCard; - - public CardSwitchButton getCurrentCard() { - return currentCard; - } - - public void setCurrentCard(CardSwitchButton currentCard) { - this.currentCard = currentCard; - } - - public int getTabFitIndex() { - return tabFitIndex; - } - - public void setTabFitIndex(int tabFitIndex) { - this.tabFitIndex = tabFitIndex; - } - - public String getTagName() { - return tagName; - } - - public void setTagName(String tagName) { - this.tagName = tagName; - } - - public boolean isSwitchingTab() { - return switchingTab; - } - - public void setSwitchingTab(boolean switchingTab) { - this.switchingTab = switchingTab; - } - - private XWCardLayout cardLayout; - - public XWCardTagLayout(WCardTagLayout widget, Dimension initSize){ - super(widget, initSize); - } - - /** - * 构造函数 - */ - public XWCardTagLayout(WCardTagLayout widget, Dimension initSize, XWCardLayout cardLayout) { - super(widget, initSize); - - this.cardLayout = cardLayout; - } - - /** - * 添加组件的监听事件 - * - * @param e 事件 - * - * - * @date 2014-11-25-下午6:20:10 - * - */ - public void componentAdded(ContainerEvent e) { - super.componentAdded(e); - - if (isSwitchingTab()){ - return; - } - - if(this.cardLayout == null){ - initCardLayout(); - } - - int index = this.cardLayout.toData().getWidgetCount(); - //新加一个card - String widgetName = tagName+getTabNameIndex(); - WTabFitLayout fitLayout = new WTabFitLayout(widgetName,tabFitIndex,currentCard); - fitLayout.setTabNameIndex(getTabNameIndex()); - XWTabFitLayout tabFitLayout = new XWTabFitLayout(fitLayout, new Dimension()); - tabFitLayout.setBackupParent(cardLayout); - cardLayout.add(tabFitLayout, widgetName); - this.cardLayout.toData().setShowIndex(index); - cardLayout.showCard(); - } - - private void initCardLayout(){ - XWCardTitleLayout titleLayout = (XWCardTitleLayout)this.getBackupParent(); - XWCardMainBorderLayout borderLayout = (XWCardMainBorderLayout)titleLayout.getBackupParent(); - - this.cardLayout = borderLayout.getCardPart(); - } - + + private static final int MIN_SIZE = 1; + + private String tagName = "Tab"; + + private boolean switchingTab = false; + + //增加一个tabNameIndex防止tabFitLayout重名 + private int tabFitIndex = 0; + private CardSwitchButton currentCard; + + public CardSwitchButton getCurrentCard() { + return currentCard; + } + + public void setCurrentCard(CardSwitchButton currentCard) { + this.currentCard = currentCard; + } + + public int getTabFitIndex() { + return tabFitIndex; + } + + public void setTabFitIndex(int tabFitIndex) { + this.tabFitIndex = tabFitIndex; + } + + public String getTagName() { + return tagName; + } + + public void setTagName(String tagName) { + this.tagName = tagName; + } + + public boolean isSwitchingTab() { + return switchingTab; + } + + public void setSwitchingTab(boolean switchingTab) { + this.switchingTab = switchingTab; + } + + private XWCardLayout cardLayout; + + public XWCardTagLayout(WCardTagLayout widget, Dimension initSize) { + super(widget, initSize); + } + + /** + * 构造函数 + */ + public XWCardTagLayout(WCardTagLayout widget, Dimension initSize, XWCardLayout cardLayout) { + super(widget, initSize); + + this.cardLayout = cardLayout; + } + + /** + * 添加组件的监听事件 + * + * @param e 事件 + * @date 2014-11-25-下午6:20:10 + */ + public void componentAdded(ContainerEvent e) { + super.componentAdded(e); + + if (isSwitchingTab()) { + return; + } + + if (this.cardLayout == null) { + initCardLayout(); + } + + int index = this.cardLayout.toData().getWidgetCount(); + //新加一个card + String widgetName = tagName + getTabNameIndex(); + WTabFitLayout fitLayout = new WTabFitLayout(widgetName, tabFitIndex, currentCard); + fitLayout.setTabNameIndex(getTabNameIndex()); + XWTabFitLayout tabFitLayout = new XWTabFitLayout(fitLayout, new Dimension()); + tabFitLayout.setBackupParent(cardLayout); + cardLayout.add(tabFitLayout, widgetName); + this.cardLayout.toData().setShowIndex(index); + cardLayout.showCard(); + } + + private void initCardLayout() { + XWCardTitleLayout titleLayout = (XWCardTitleLayout) this.getBackupParent(); + XWCardMainBorderLayout borderLayout = (XWCardMainBorderLayout) titleLayout.getBackupParent(); + + this.cardLayout = borderLayout.getCardPart(); + } + /** * 将WLayout转换为XLayoutContainer */ public void convert() { isRefreshing = true; - WCardTagLayout layout = (WCardTagLayout)this.toData(); + WCardTagLayout layout = (WCardTagLayout) this.toData(); this.removeAll(); for (int i = 0; i < layout.getWidgetCount(); i++) { Widget wgt = layout.getWidget(i); @@ -144,82 +139,81 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout { } isRefreshing = false; } - + /** * 切换到非添加状态 - * + * * @return designer 表单设计器 */ - public void stopAddingState(FormDesigner designer){ - designer.stopAddingState(); - return; + public void stopAddingState(FormDesigner designer) { + designer.stopAddingState(); } - + //新增时去tabFitLayout名字中最大的Index+1,防止重名 - private int getTabNameIndex(){ - int tabNameIndex = 0; - WCardLayout layout = this.cardLayout.toData(); - int size = layout.getWidgetCount(); - if(size < MIN_SIZE){ - return tabNameIndex; - } - for(int i=0;i + * void + */ + public void adjustComponentWidth() { + } + + + /** + * 该布局需要隐藏,无需对边框进行操作 + * + * @param + */ public void setBorder(Border border) { - return; - } - - @Override - /** - * 该布局隐藏,点击该布局时选中相应的tab布局主体 - * @param editingMouseListener 监听 - * @param e 鼠标点击事件 - * - */ - public void respondClick(EditingMouseListener editingMouseListener, - MouseEvent e) { - FormDesigner designer = editingMouseListener.getDesigner(); - SelectionModel selectionModel = editingMouseListener.getSelectionModel(); - - XWCardTitleLayout titleLayout = (XWCardTitleLayout) this.getBackupParent(); - if(titleLayout != null){ - XWCardMainBorderLayout mainLayout = (XWCardMainBorderLayout)titleLayout.getBackupParent(); - if(mainLayout != null){ - XWCardLayout cardLayout = mainLayout.getCardPart(); - selectionModel.setSelectedCreator(cardLayout); - } - } - - if (editingMouseListener.stopEditing()) { - if (this != designer.getRootComponent()) { - ComponentAdapter adapter = AdapterBus.getComponentAdapter(designer, this); - editingMouseListener.startEditing(this, adapter.getDesignerEditor(), adapter); - } - } - } - - @Override - public XLayoutContainer getTopLayout() { - return this.getBackupParent().getTopLayout(); - } + + } + + @Override + /** + * 该布局隐藏,点击该布局时选中相应的tab布局主体 + * @param editingMouseListener 监听 + * @param e 鼠标点击事件 + * + */ + public void respondClick(EditingMouseListener editingMouseListener, + MouseEvent e) { + FormDesigner designer = editingMouseListener.getDesigner(); + SelectionModel selectionModel = editingMouseListener.getSelectionModel(); + + XWCardTitleLayout titleLayout = (XWCardTitleLayout) this.getBackupParent(); + if (titleLayout != null) { + XWCardMainBorderLayout mainLayout = (XWCardMainBorderLayout) titleLayout.getBackupParent(); + if (mainLayout != null) { + XWCardLayout cardLayout = mainLayout.getCardPart(); + selectionModel.setSelectedCreator(cardLayout); + } + } + + if (editingMouseListener.stopEditing()) { + if (this != designer.getRootComponent()) { + ComponentAdapter adapter = AdapterBus.getComponentAdapter(designer, this); + editingMouseListener.startEditing(this, adapter.getDesignerEditor(), adapter); + } + } + } + + @Override + public XLayoutContainer getTopLayout() { + return this.getBackupParent().getTopLayout(); + } } \ No newline at end of file diff --git a/designer_form/src/com/fr/design/mainframe/FormCreatorDropTarget.java b/designer_form/src/com/fr/design/mainframe/FormCreatorDropTarget.java index 6390b64f89..486ad26949 100644 --- a/designer_form/src/com/fr/design/mainframe/FormCreatorDropTarget.java +++ b/designer_form/src/com/fr/design/mainframe/FormCreatorDropTarget.java @@ -43,7 +43,7 @@ public class FormCreatorDropTarget extends DropTarget { * 当前添加模式对应的model */ private AddingModel addingModel; - private final static int GAP = 30; + private static final int GAP = 30; private JWindow promptWindow = new JWindow(); private UIButton promptButton = new UIButton("", BaseUtils.readIcon(IconPathConstants.FORBID_ICON_PATH)); @@ -59,10 +59,11 @@ public class FormCreatorDropTarget extends DropTarget { XCreator hoveredComponent = designer.getComponentAt(x, y); // 获取该组件所在的焦点容器 XLayoutContainer container = XCreatorUtils.getHotspotContainer(hoveredComponent); - //cardTagLayout里用到 - container.stopAddingState(designer); boolean success = false; if (container != null) { + //XWCardTagLayout 切换添加状态到普通状态 + container.stopAddingState(designer); + // 如果是容器,则调用其acceptComponent接受组件 AddingModel model = designer.getAddingModel(); @@ -129,9 +130,7 @@ public class FormCreatorDropTarget extends DropTarget { //提示组件是否可以拖入 promptUser(x, y, container); if (container != null) { - dealWithContainer(x, y, container); - } else { // 如果鼠标不在任何组件上,则取消提示器 designer.setPainter(null); @@ -197,11 +196,9 @@ public class FormCreatorDropTarget extends DropTarget { private void promptWidgetForbidEnter(int x, int y, XLayoutContainer container) { container.setBorder(BorderFactory.createLineBorder(Color.RED, Constants.LINE_MEDIUM)); - int screen_X = (int) designer.getArea().getLocationOnScreen().getX(); - int screen_Y = (int) designer.getArea().getLocationOnScreen().getY(); - this.promptWindow.setSize(promptWindow.getPreferredSize()); - this.promptWindow.setPreferredSize(promptWindow.getPreferredSize()); - promptWindow.setLocation(screen_X + x + GAP, screen_Y + y + GAP); + int screenX = designer.getArea().getLocationOnScreen().x; + int screenY = designer.getArea().getLocationOnScreen().y; + promptWindow.setLocation(screenX + x + GAP, screenY + y + GAP); promptWindow.setVisible(true); } diff --git a/designer_form/src/com/fr/design/mainframe/FormDesigner.java b/designer_form/src/com/fr/design/mainframe/FormDesigner.java index 1dd61c5597..0c77059935 100644 --- a/designer_form/src/com/fr/design/mainframe/FormDesigner.java +++ b/designer_form/src/com/fr/design/mainframe/FormDesigner.java @@ -612,6 +612,12 @@ public class FormDesigner extends TargetComponent
implements TreeSelection return true; } + public void showMessageDialog(String message) { + JOptionPane.showMessageDialog(this, message, Inter.getLocText("FR-Designer_Alert"), JOptionPane.WARNING_MESSAGE); + FormSelectionUtils.rebuildSelection(this); + repaint(); + } + /** * 保存参数界面的宽度 * diff --git a/designer_form/src/com/fr/design/mainframe/FormSelection.java b/designer_form/src/com/fr/design/mainframe/FormSelection.java index f30cf2e84f..ff809371c5 100644 --- a/designer_form/src/com/fr/design/mainframe/FormSelection.java +++ b/designer_form/src/com/fr/design/mainframe/FormSelection.java @@ -8,12 +8,7 @@ import com.fr.base.FRContext; import com.fr.design.designer.beans.AdapterBus; import com.fr.design.designer.beans.LayoutAdapter; import com.fr.design.designer.beans.location.Direction; -import com.fr.design.designer.creator.XComponent; -import com.fr.design.designer.creator.XCreator; -import com.fr.design.designer.creator.XCreatorUtils; -import com.fr.design.designer.creator.XLayoutContainer; -import com.fr.design.designer.creator.XWAbsoluteLayout; -import com.fr.design.designer.creator.XWParameterLayout; +import com.fr.design.designer.creator.*; import com.fr.form.ui.Widget; import com.fr.design.utils.ComponentUtils; import com.fr.design.utils.gui.LayoutUtils; @@ -273,6 +268,11 @@ public class FormSelection { if (parent == null) { return; } + boolean changeCreator = creator.shouldScaleCreator() || creator.hasTitleStyle(); + if (parent.acceptType(XWFitLayout.class) && changeCreator) { + creator = (XCreator) creator.getParent(); + } + parent.getLayoutAdapter().removeBean(creator, creator.getWidth(), creator.getHeight()); // 删除其根组件,同时就删除了同时被选择的叶子组件 parent.remove(creator); LayoutManager layout = parent.getLayout(); diff --git a/designer_form/src/com/fr/design/mainframe/FormSelectionUtils.java b/designer_form/src/com/fr/design/mainframe/FormSelectionUtils.java index ff976ef771..79f52519ec 100644 --- a/designer_form/src/com/fr/design/mainframe/FormSelectionUtils.java +++ b/designer_form/src/com/fr/design/mainframe/FormSelectionUtils.java @@ -8,6 +8,7 @@ import com.fr.design.designer.creator.*; import com.fr.form.ui.Widget; import com.fr.form.ui.container.WTitleLayout; import com.fr.general.ComparatorUtils; +import com.fr.general.Inter; import java.awt.*; import java.util.ArrayList; @@ -17,11 +18,7 @@ import java.util.List; public class FormSelectionUtils { //组件复制时坐标偏移 - private static final int DELAY_X = 20; - private static final int DELAY_Y = 20; - - //组件复制时是否已经向左上偏移 - private static boolean backoffset = false; + private static final int DELAY_X_Y = 20; //组件重命名后缀 private static final String POSTFIX = "_c"; @@ -31,11 +28,7 @@ public class FormSelectionUtils { } /** - * @param designer 编辑器 - * @param parent 粘贴依据的组件 - * @param clipboard 剪贴板内容 - * @param x x - * @param y y + * 粘贴到容器 */ public static void paste2Container(FormDesigner designer, XLayoutContainer parent, FormSelection clipboard, int x, int y) { @@ -54,12 +47,6 @@ public class FormSelectionUtils { /** * 绝对布局粘贴 - * - * @param designer - * @param clipboard - * @param adapter - * @param x - * @param y */ private static void absolutePaste(FormDesigner designer, FormSelection clipboard, LayoutAdapter adapter, int x, int y) { @@ -74,6 +61,10 @@ public class FormSelectionUtils { copiedCreator, x + creator.getX() - rec.x + copiedCreator.getWidth() / 2, y + creator.getY() - rec.y + copiedCreator.getHeight() / 2); + if (!adapter.accept(copiedCreator, point.x, point.y)) { + designer.showMessageDialog(Inter.getLocText("FR-Designer_Too_Large_To_Paste")); + return; + } boolean addSuccess = adapter.addBean(copiedCreator, point.x, point.y); if (addSuccess) { designer.getSelectionModel().getSelection().addSelectedCreator(copiedCreator); @@ -90,12 +81,6 @@ public class FormSelectionUtils { /** * 相对布局粘贴 - * - * @param designer - * @param clipboard - * @param adapter - * @param x - * @param y */ private static void relativePaste(FormDesigner designer, FormSelection clipboard, LayoutAdapter adapter, int x, int y) { designer.getSelectionModel().getSelection().reset(); @@ -103,6 +88,10 @@ public class FormSelectionUtils { try { Widget copied = copyWidget(designer, creator); XCreator copiedCreator = XCreatorUtils.createXCreator(copied, creator.getSize()); + if (!adapter.accept(copiedCreator, x, y)) { + designer.showMessageDialog(Inter.getLocText("FR-Designer_Too_Small_To_Paste")); + return; + } boolean addSuccess = adapter.addBean(copiedCreator, x, y); if (addSuccess) { designer.getSelectionModel().getSelection().addSelectedCreator(copiedCreator); @@ -118,14 +107,6 @@ public class FormSelectionUtils { /** * 组件复用绝对布局获取粘贴组件位置 - * - * @param layoutAdapter 绝对布局容器AbstractLayoutAdapter - * @param copiedCreator 复制的组件 - * @param x x=组件x + clonedCreator.getWidth() / 2 - * @param y y=组件y + clonedCreator.getHeight() / 2 - * 除2的步骤会导致当宽度或者高度为奇数是,中心点向左上各偏移一个像素 - * 由于中心点向左上各偏移一个像素,依赖中心点计算的右下点就会相应的想做上偏移一个像素,导致结果不准确 - * @return 新位置坐标 */ private static Point getPasteLocation(AbstractLayoutAdapter layoutAdapter, XCreator copiedCreator, int x, int y) { //当宽度为奇数时 设置偏移 @@ -144,12 +125,10 @@ public class FormSelectionUtils { * x,y同时越界 */ if (xOut && yOut) { - x = backoffset ? container.getWidth() - copiedCreator.getWidth() / 2 - xoffset - : container.getWidth() - copiedCreator.getWidth() / 2 - DELAY_X - xoffset; - y = backoffset ? - container.getHeight() - copiedCreator.getHeight() / 2 - yoffset - : container.getHeight() - copiedCreator.getHeight() / 2 - DELAY_Y - yoffset; - backoffset = !backoffset; + //向左偏移 + x = container.getWidth() - copiedCreator.getWidth() / 2 - DELAY_X_Y - xoffset; + //紧贴下边界 + y = container.getHeight() - copiedCreator.getHeight() / 2 - yoffset; return new Point(x, y); } /* @@ -158,7 +137,7 @@ public class FormSelectionUtils { * 距离大于20像素的一侧正常错开。 * x,y中只有一个越界 */ - else if ((xOut || yOut)) { + if ((xOut || yOut)) { x = xOut ? container.getWidth() - copiedCreator.getWidth() / 2 - xoffset : x; y = yOut ? container.getHeight() - copiedCreator.getHeight() / 2 - yoffset : y; return new Point(x, y); @@ -170,15 +149,10 @@ public class FormSelectionUtils { /** * 拷贝组件 - * - * @param formDesigner - * @param xCreator - * @return - * @throws CloneNotSupportedException */ private static Widget copyWidget(FormDesigner formDesigner, XCreator xCreator) throws CloneNotSupportedException { - ArrayList nameSpace = new ArrayList(); + ArrayList nameSpace = new ArrayList<>(); Widget copied = (Widget) xCreator.toData().clone(); //重命名拷贝的组件 String name = getCopiedName(formDesigner, copied, nameSpace); @@ -193,14 +167,9 @@ public class FormSelectionUtils { /** * 组件拷贝命名规则 - * - * @param formDesigner - * @param copied - * @param nameSpace - * @return name */ private static String getCopiedName(FormDesigner formDesigner, Widget copied, ArrayList nameSpace) { - StringBuffer name = new StringBuffer(copied.getWidgetName()); + StringBuilder name = new StringBuilder(copied.getWidgetName()); do { name.append(POSTFIX); } while (formDesigner.getTarget().isNameExist(name.toString()) || nameSpace.contains(name.toString())); @@ -209,8 +178,8 @@ public class FormSelectionUtils { } public static void rebuildSelection(FormDesigner designer) { - ArrayList newSelection = new ArrayList(); - List widgetList = new ArrayList(); + ArrayList newSelection = new ArrayList<>(); + List widgetList = new ArrayList<>(); for (XCreator comp : designer.getSelectionModel().getSelection().getSelectedCreators()) { widgetList.add(comp.toData()); } @@ -219,7 +188,7 @@ public class FormSelectionUtils { } public static ArrayList rebuildSelection(XCreator rootComponent, Widget[] selectWidgets) { - List selectionWidget = new ArrayList(); + List selectionWidget = new ArrayList<>(); if (selectWidgets != null) { selectionWidget.addAll(Arrays.asList(selectWidgets)); }