From ce9c9eecd0dc2d3305f93e74a1c1652011bb01de Mon Sep 17 00:00:00 2001 From: daniel Date: Tue, 27 Dec 2016 17:25:35 +0800 Subject: [PATCH 01/22] =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer_base/src/com/fr/design/fun/ConnectionProvider.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer_base/src/com/fr/design/fun/ConnectionProvider.java b/designer_base/src/com/fr/design/fun/ConnectionProvider.java index c6bd2fca2..bb646c48d 100644 --- a/designer_base/src/com/fr/design/fun/ConnectionProvider.java +++ b/designer_base/src/com/fr/design/fun/ConnectionProvider.java @@ -12,7 +12,7 @@ public interface ConnectionProvider extends Mutable { public static final String XML_TAG = "ConnectionProvider"; - int CURRENT_LEVEL = 1; + int CURRENT_LEVEL = 2; /** * 数据连接弹出菜单的名字 From 7a20e537115d8250cd81e2a8062dd715d2c5830a Mon Sep 17 00:00:00 2001 From: daniel Date: Tue, 27 Dec 2016 17:45:43 +0800 Subject: [PATCH 02/22] roll back --- designer_base/src/com/fr/design/fun/ConnectionProvider.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer_base/src/com/fr/design/fun/ConnectionProvider.java b/designer_base/src/com/fr/design/fun/ConnectionProvider.java index bb646c48d..c6bd2fca2 100644 --- a/designer_base/src/com/fr/design/fun/ConnectionProvider.java +++ b/designer_base/src/com/fr/design/fun/ConnectionProvider.java @@ -12,7 +12,7 @@ public interface ConnectionProvider extends Mutable { public static final String XML_TAG = "ConnectionProvider"; - int CURRENT_LEVEL = 2; + int CURRENT_LEVEL = 1; /** * 数据连接弹出菜单的名字 From 7c9c93d94ad6fc03d2e9f7a27ba5533940a91f44 Mon Sep 17 00:00:00 2001 From: daniel Date: Tue, 7 Mar 2017 15:13:35 +0800 Subject: [PATCH 03/22] diamond --- designer/src/com/fr/design/present/PresentPane.java | 8 ++++---- .../src/com/fr/design/report/ReportExportAttrPane.java | 2 +- designer/src/com/fr/design/report/VerifierListPane.java | 2 +- .../com/fr/design/write/submit/SubmitVisitorListPane.java | 8 ++++---- .../designer/creator/cardlayout/XCardSwitchButton.java | 4 ++-- .../properties/mobile/ElementCasePropertyTable.java | 2 +- .../src/com/fr/design/gui/xtable/PropertyGroupModel.java | 2 +- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/designer/src/com/fr/design/present/PresentPane.java b/designer/src/com/fr/design/present/PresentPane.java index 043b069b0..7d1d571fc 100644 --- a/designer/src/com/fr/design/present/PresentPane.java +++ b/designer/src/com/fr/design/present/PresentPane.java @@ -57,12 +57,12 @@ public class PresentPane extends UIComboBoxPane { @Override protected List> initPaneList() { if (keys == null) { - keys = new ArrayList<>(); + keys = new ArrayList(); } if (displays == null) { - displays = new ArrayList<>(); + displays = new ArrayList(); } - List> paneList = new ArrayList<>(); + List> paneList = new ArrayList>(); FurtherBasicBeanPane none = new NonePresentPane(); paneList.add(none); keys.add("NOPRESENT"); @@ -99,7 +99,7 @@ public class PresentPane extends UIComboBoxPane { @Override protected UIComboBox createComboBox() { - return new DictionaryComboBox<>(keys.toArray(new String[keys.size()]), displays.toArray(new String[displays.size()])); + return new DictionaryComboBox(keys.toArray(new String[keys.size()]), displays.toArray(new String[displays.size()])); } @Override diff --git a/designer/src/com/fr/design/report/ReportExportAttrPane.java b/designer/src/com/fr/design/report/ReportExportAttrPane.java index 33eb07519..1f549c62e 100644 --- a/designer/src/com/fr/design/report/ReportExportAttrPane.java +++ b/designer/src/com/fr/design/report/ReportExportAttrPane.java @@ -31,7 +31,7 @@ public class ReportExportAttrPane extends BasicPane { wordExportPane = new WordExportPane(); uiTabbedPane.addTab("Word", wordExportPane); Set providers = ExtraDesignClassManager.getInstance().getArray(ExportAttrTabProvider.XML_TAG); - paneList = new ArrayList<>(); + paneList = new ArrayList(); for (ExportAttrTabProvider provider : providers) { uiTabbedPane.addTab(provider.title(), provider.toSwingComponent()); paneList.add(provider.toExportPane()); diff --git a/designer/src/com/fr/design/report/VerifierListPane.java b/designer/src/com/fr/design/report/VerifierListPane.java index 9bdedbd8a..15b69398b 100644 --- a/designer/src/com/fr/design/report/VerifierListPane.java +++ b/designer/src/com/fr/design/report/VerifierListPane.java @@ -1 +1 @@ -package com.fr.design.report; import com.fr.data.Verifier; import com.fr.design.ExtraDesignClassManager; import com.fr.design.fun.VerifyDefineProvider; import com.fr.design.gui.controlpane.NameObjectCreator; import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.controlpane.ObjectJControlPane; import com.fr.design.mainframe.ElementCasePane; import com.fr.general.Inter; import com.fr.general.NameObject; import com.fr.report.write.ReportWriteAttr; import com.fr.report.write.ValueVerifier; import com.fr.report.write.WClassVerifier; import com.fr.stable.ArrayUtils; import com.fr.stable.Nameable; import java.util.ArrayList; import java.util.Set; /** * 校验列表 */ public class VerifierListPane extends ObjectJControlPane { public VerifierListPane(ElementCasePane ePane) { super(ePane); } /** * 创建选项 * * @return 选项 */ public NameableCreator[] createNameableCreators() { NameableCreator[] creators = new NameableCreator[]{ new NameObjectCreator(Inter.getLocText(new String[]{"BuildIn", "Verify"}), "/com/fr/web/images/reportlet.png", ValueVerifier.class, BuildInVerifierPane.class) }; Set set = ExtraDesignClassManager.getInstance().getArray(VerifyDefineProvider.MARK_STRING); for (VerifyDefineProvider provider : set) { creators = ArrayUtils.add(creators, new NameObjectCreator( provider.nameForVerifier(), provider.iconPath(), provider.classForVerifier(), provider.appearanceForVerifier() ) { }); } creators = ArrayUtils.add(creators, new NameObjectCreator( Inter.getLocText(new String[]{"Custom", "Verify"}), "/com/fr/web/images/reportlet.png", WClassVerifier.class, CustomVerifierPane.class)); return creators; } @Override protected String title4PopupWindow() { return "Verify Collections"; } public void populate(ReportWriteAttr reportWriteAttr) { if (reportWriteAttr == null) { return; } java.util.List nameObjectList = new ArrayList<>(); int verifierCount = reportWriteAttr.getVerifierCount(); for (int i = 0; i < verifierCount; i++) { Verifier verifier = reportWriteAttr.getVerifier(i); nameObjectList.add(new NameObject(verifier.getName(), verifier)); } this.populate(nameObjectList.toArray(new NameObject[nameObjectList.size()])); } public void updateReportWriteAttr(ReportWriteAttr reportWriteAttr) { // Nameable[]居然不能强转成NameObject[],一定要这么写... Nameable[] res = this.update(); NameObject[] res_array = new NameObject[res.length]; java.util.Arrays.asList(res).toArray(res_array); reportWriteAttr.clearVerifiers(); for (int i = 0; i < res_array.length; i++) { NameObject nameObject = res_array[i]; if (nameObject.getObject() instanceof Verifier) { Verifier verifier = (Verifier) nameObject.getObject(); verifier.setName(nameObject.getName()); reportWriteAttr.addVerifier(verifier); } } } } \ No newline at end of file +package com.fr.design.report; import com.fr.data.Verifier; import com.fr.design.ExtraDesignClassManager; import com.fr.design.fun.VerifyDefineProvider; import com.fr.design.gui.controlpane.NameObjectCreator; import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.controlpane.ObjectJControlPane; import com.fr.design.mainframe.ElementCasePane; import com.fr.general.Inter; import com.fr.general.NameObject; import com.fr.report.write.ReportWriteAttr; import com.fr.report.write.ValueVerifier; import com.fr.report.write.WClassVerifier; import com.fr.stable.ArrayUtils; import com.fr.stable.Nameable; import java.util.ArrayList; import java.util.Set; /** * 校验列表 */ public class VerifierListPane extends ObjectJControlPane { public VerifierListPane(ElementCasePane ePane) { super(ePane); } /** * 创建选项 * * @return 选项 */ public NameableCreator[] createNameableCreators() { NameableCreator[] creators = new NameableCreator[]{ new NameObjectCreator(Inter.getLocText(new String[]{"BuildIn", "Verify"}), "/com/fr/web/images/reportlet.png", ValueVerifier.class, BuildInVerifierPane.class) }; Set set = ExtraDesignClassManager.getInstance().getArray(VerifyDefineProvider.MARK_STRING); for (VerifyDefineProvider provider : set) { creators = ArrayUtils.add(creators, new NameObjectCreator( provider.nameForVerifier(), provider.iconPath(), provider.classForVerifier(), provider.appearanceForVerifier() ) { }); } creators = ArrayUtils.add(creators, new NameObjectCreator( Inter.getLocText(new String[]{"Custom", "Verify"}), "/com/fr/web/images/reportlet.png", WClassVerifier.class, CustomVerifierPane.class)); return creators; } @Override protected String title4PopupWindow() { return "Verify Collections"; } public void populate(ReportWriteAttr reportWriteAttr) { if (reportWriteAttr == null) { return; } java.util.List nameObjectList = new ArrayList(); int verifierCount = reportWriteAttr.getVerifierCount(); for (int i = 0; i < verifierCount; i++) { Verifier verifier = reportWriteAttr.getVerifier(i); nameObjectList.add(new NameObject(verifier.getName(), verifier)); } this.populate(nameObjectList.toArray(new NameObject[nameObjectList.size()])); } public void updateReportWriteAttr(ReportWriteAttr reportWriteAttr) { // Nameable[]居然不能强转成NameObject[],一定要这么写... Nameable[] res = this.update(); NameObject[] res_array = new NameObject[res.length]; java.util.Arrays.asList(res).toArray(res_array); reportWriteAttr.clearVerifiers(); for (int i = 0; i < res_array.length; i++) { NameObject nameObject = res_array[i]; if (nameObject.getObject() instanceof Verifier) { Verifier verifier = (Verifier) nameObject.getObject(); verifier.setName(nameObject.getName()); reportWriteAttr.addVerifier(verifier); } } } } \ No newline at end of file diff --git a/designer/src/com/fr/design/write/submit/SubmitVisitorListPane.java b/designer/src/com/fr/design/write/submit/SubmitVisitorListPane.java index 3dfea6c15..899017003 100644 --- a/designer/src/com/fr/design/write/submit/SubmitVisitorListPane.java +++ b/designer/src/com/fr/design/write/submit/SubmitVisitorListPane.java @@ -68,7 +68,7 @@ public class SubmitVisitorListPane extends ObjectJControlPane { return; } - List nameObjectList = new ArrayList<>(); + List nameObjectList = new ArrayList(); int submiterCount = reportWriteAttr.getSubmitVisitorCount(); for (int i = 0; i < submiterCount; i++) { @@ -169,8 +169,8 @@ public class SubmitVisitorListPane extends ObjectJControlPane { public CustomPane() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); customCardPane = FRGUIPaneFactory.createCardLayout_S_Pane(); - customSubmitPanes = new HashMap<>(); - comboItemsMap = new HashMap<>(); + customSubmitPanes = new HashMap(); + comboItemsMap = new HashMap(); Set providers = ExtraDesignClassManager.getInstance().getArray(SubmitProvider.MARK_STRING); addSubmitPane(new DefaultSubmit()); @@ -178,7 +178,7 @@ public class SubmitVisitorListPane extends ObjectJControlPane { addSubmitPane(provider); } - configTypes = new ArrayList<>(); + configTypes = new ArrayList(); for (Map.Entry entry : customSubmitPanes.entrySet()) { String key = entry.getKey(); configTypes.add(comboItemsMap.get(key)); diff --git a/designer_form/src/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java b/designer_form/src/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java index 04e678029..7189687d6 100644 --- a/designer_form/src/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java +++ b/designer_form/src/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java @@ -389,8 +389,8 @@ public class XCardSwitchButton extends XButton { return; } int tabLength = this.tagLayout.getComponentCount(); - Map cardWidth = new HashMap<>(); - Map cardHeight = new HashMap<>(); + Map cardWidth = new HashMap(); + Map cardHeight = new HashMap(); for (int i = 0; i < tabLength; i++) { XCardSwitchButton temp = (XCardSwitchButton) this.tagLayout.getComponent(i); CardSwitchButton tempCard = (CardSwitchButton) temp.toData(); diff --git a/designer_form/src/com/fr/design/designer/properties/mobile/ElementCasePropertyTable.java b/designer_form/src/com/fr/design/designer/properties/mobile/ElementCasePropertyTable.java index 5a156f346..3522c32b2 100644 --- a/designer_form/src/com/fr/design/designer/properties/mobile/ElementCasePropertyTable.java +++ b/designer_form/src/com/fr/design/designer/properties/mobile/ElementCasePropertyTable.java @@ -60,7 +60,7 @@ public class ElementCasePropertyTable extends AbstractPropertyTable{ .setRendererClass(BooleanRender.class) .putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, Inter.getLocText("FR-Designer_Fit")) }; - List defaultList = new ArrayList<>(); + List defaultList = new ArrayList(); for (CRPropertyDescriptor propertyDescriptor: propertyTableEditor) { defaultList.add(propertyDescriptor); diff --git a/designer_form/src/com/fr/design/gui/xtable/PropertyGroupModel.java b/designer_form/src/com/fr/design/gui/xtable/PropertyGroupModel.java index bb0f0cd3a..50f234324 100644 --- a/designer_form/src/com/fr/design/gui/xtable/PropertyGroupModel.java +++ b/designer_form/src/com/fr/design/gui/xtable/PropertyGroupModel.java @@ -54,7 +54,7 @@ public class PropertyGroupModel extends AbstractPropertyGroupModel { creator.resetCreatorName(value.toString()); } if(ComparatorUtils.equals("visible", properties[row].getName())){ - creator.resetVisible((boolean) value); + creator.resetVisible((Boolean) value); } properties[row].firePropertyChanged(); return true; From b43d2185ec20ea375d0ad6eca4329d70019a562d Mon Sep 17 00:00:00 2001 From: daniel Date: Wed, 19 Jul 2017 09:45:36 +0800 Subject: [PATCH 04/22] jdk --- .../fr/design/report/VerifierListPane.java | 101 +++++++++++++++++- 1 file changed, 100 insertions(+), 1 deletion(-) diff --git a/designer/src/com/fr/design/report/VerifierListPane.java b/designer/src/com/fr/design/report/VerifierListPane.java index 15b69398b..6b34af21b 100644 --- a/designer/src/com/fr/design/report/VerifierListPane.java +++ b/designer/src/com/fr/design/report/VerifierListPane.java @@ -1 +1,100 @@ -package com.fr.design.report; import com.fr.data.Verifier; import com.fr.design.ExtraDesignClassManager; import com.fr.design.fun.VerifyDefineProvider; import com.fr.design.gui.controlpane.NameObjectCreator; import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.controlpane.ObjectJControlPane; import com.fr.design.mainframe.ElementCasePane; import com.fr.general.Inter; import com.fr.general.NameObject; import com.fr.report.write.ReportWriteAttr; import com.fr.report.write.ValueVerifier; import com.fr.report.write.WClassVerifier; import com.fr.stable.ArrayUtils; import com.fr.stable.Nameable; import java.util.ArrayList; import java.util.Set; /** * 校验列表 */ public class VerifierListPane extends ObjectJControlPane { public VerifierListPane(ElementCasePane ePane) { super(ePane); } /** * 创建选项 * * @return 选项 */ public NameableCreator[] createNameableCreators() { NameableCreator[] creators = new NameableCreator[]{ new NameObjectCreator(Inter.getLocText(new String[]{"BuildIn", "Verify"}), "/com/fr/web/images/reportlet.png", ValueVerifier.class, BuildInVerifierPane.class) }; Set set = ExtraDesignClassManager.getInstance().getArray(VerifyDefineProvider.MARK_STRING); for (VerifyDefineProvider provider : set) { creators = ArrayUtils.add(creators, new NameObjectCreator( provider.nameForVerifier(), provider.iconPath(), provider.classForVerifier(), provider.appearanceForVerifier() ) { }); } creators = ArrayUtils.add(creators, new NameObjectCreator( Inter.getLocText(new String[]{"Custom", "Verify"}), "/com/fr/web/images/reportlet.png", WClassVerifier.class, CustomVerifierPane.class)); return creators; } @Override protected String title4PopupWindow() { return "Verify Collections"; } public void populate(ReportWriteAttr reportWriteAttr) { if (reportWriteAttr == null) { return; } java.util.List nameObjectList = new ArrayList(); int verifierCount = reportWriteAttr.getVerifierCount(); for (int i = 0; i < verifierCount; i++) { Verifier verifier = reportWriteAttr.getVerifier(i); nameObjectList.add(new NameObject(verifier.getName(), verifier)); } this.populate(nameObjectList.toArray(new NameObject[nameObjectList.size()])); } public void updateReportWriteAttr(ReportWriteAttr reportWriteAttr) { // Nameable[]居然不能强转成NameObject[],一定要这么写... Nameable[] res = this.update(); NameObject[] res_array = new NameObject[res.length]; java.util.Arrays.asList(res).toArray(res_array); reportWriteAttr.clearVerifiers(); for (int i = 0; i < res_array.length; i++) { NameObject nameObject = res_array[i]; if (nameObject.getObject() instanceof Verifier) { Verifier verifier = (Verifier) nameObject.getObject(); verifier.setName(nameObject.getName()); reportWriteAttr.addVerifier(verifier); } } } } \ No newline at end of file +package com.fr.design.report; + +import com.fr.data.Verifier; +import com.fr.design.ExtraDesignClassManager; +import com.fr.design.fun.VerifyDefineProvider; +import com.fr.design.gui.controlpane.NameObjectCreator; +import com.fr.design.gui.controlpane.NameableCreator; +import com.fr.design.gui.controlpane.ObjectJControlPane; +import com.fr.design.mainframe.ElementCasePane; +import com.fr.general.Inter; +import com.fr.general.NameObject; +import com.fr.report.write.ReportWriteAttr; +import com.fr.report.write.ValueVerifier; +import com.fr.report.write.WClassVerifier; +import com.fr.stable.ArrayUtils; +import com.fr.stable.Nameable; + +import java.util.ArrayList; +import java.util.Set; + +/** + * 校验列表 + */ +public class VerifierListPane extends ObjectJControlPane { + + public VerifierListPane(ElementCasePane ePane) { + super(ePane); + } + + /** + * 创建选项 + * + * @return 选项 + */ + public NameableCreator[] createNameableCreators() { + NameableCreator[] creators = new NameableCreator[]{ + new NameObjectCreator(Inter.getLocText(new String[]{"BuildIn", "Verify"}), + "/com/fr/web/images/reportlet.png", + ValueVerifier.class, + BuildInVerifierPane.class) + }; + Set set = ExtraDesignClassManager.getInstance().getArray(VerifyDefineProvider.MARK_STRING); + for (VerifyDefineProvider provider : set) { + creators = ArrayUtils.add(creators, new NameObjectCreator( + provider.nameForVerifier(), + provider.iconPath(), + provider.classForVerifier(), + provider.appearanceForVerifier() + ) { + }); + } + creators = ArrayUtils.add(creators, new NameObjectCreator( + Inter.getLocText(new String[]{"Custom", "Verify"}), + "/com/fr/web/images/reportlet.png", + WClassVerifier.class, + CustomVerifierPane.class)); + return creators; + } + + @Override + protected String title4PopupWindow() { + return "Verify Collections"; + } + + public void populate(ReportWriteAttr reportWriteAttr) { + if (reportWriteAttr == null) { + return; + } + + java.util.List nameObjectList = new ArrayList(); + + int verifierCount = reportWriteAttr.getVerifierCount(); + for (int i = 0; i < verifierCount; i++) { + Verifier verifier = reportWriteAttr.getVerifier(i); + nameObjectList.add(new NameObject(verifier.getName(), verifier)); + } + + this.populate(nameObjectList.toArray(new NameObject[nameObjectList.size()])); + } + + public void updateReportWriteAttr(ReportWriteAttr reportWriteAttr) { + // Nameable[]居然不能强转成NameObject[],一定要这么写... + Nameable[] res = this.update(); + NameObject[] res_array = new NameObject[res.length]; + java.util.Arrays.asList(res).toArray(res_array); + + reportWriteAttr.clearVerifiers(); + + for (int i = 0; i < res_array.length; i++) { + NameObject nameObject = res_array[i]; + if (nameObject.getObject() instanceof Verifier) { + Verifier verifier = (Verifier) nameObject.getObject(); + verifier.setName(nameObject.getName()); + reportWriteAttr.addVerifier(verifier); + } + } + } + + +} \ No newline at end of file From 24cd9cf3a55673c3ea512fa5aac46dfad50b62c5 Mon Sep 17 00:00:00 2001 From: daniel Date: Tue, 1 Aug 2017 15:35:38 +0800 Subject: [PATCH 05/22] build change --- build.performance.gradle | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/build.performance.gradle b/build.performance.gradle index 102205679..1efdd55cc 100644 --- a/build.performance.gradle +++ b/build.performance.gradle @@ -3,22 +3,32 @@ tasks.withType(JavaCompile){ options.encoding = "UTF-8" } -def basicDir="../" -def libDir="${basicDir}/lib" +def basicDir="../../" +def libDir="${basicDir}/finereport-lib-stable" +//获取什么分支名 +FileTree files =fileTree(dir:"./",include:"build.*.gradle") +def buildDir=files[0].path.substring(0,files[0].path.lastIndexOf ("\\")) +def branchName=buildDir.substring(buildDir.lastIndexOf ("\\")+1) task appletJar<<{ + ant{ mkdir(dir:"./tmp") - mkdir(dir:"build/classes/main") + mkdir(dir:"build/classes/") copy(todir:"build/classes/"){ - fileset(dir:"${basicDir}/core/build/classes/main") - fileset(dir:"${basicDir}/chart/build/classes/main") - fileset(dir:"${basicDir}/report/build/classes/main") - fileset(dir:"${basicDir}/platform/build/classes/main") - fileset(dir:"${basicDir}/performance/build/classes/main") + fileset(dir:"${basicDir}/finereport-core-stable/${branchName}/build/classes/main") + + fileset(dir:"${basicDir}/finereport-chart-stable/${branchName}/build/classes/main") + + fileset(dir:"${basicDir}/finereport-report-stable/${branchName}/build/classes/main") + + fileset(dir:"${basicDir}/finereport-platform-stable/${branchName}/build/classes/main") + + fileset(dir:"${basicDir}/finereport-performance-stable/${branchName}/build/classes/main") + } - unjar(src:"${libDir}/3rd.jar",dest:"./tmp") - unjar(src:"${libDir}/servlet-api.jar",dest:"./tmp") + unjar(src:"${libDir}/${branchName}/3rd.jar",dest:"./tmp") + unjar(src:"${libDir}/${branchName}/servlet-api.jar",dest:"./tmp") jar(jarfile:"build/libs/fr-applet-8.0.jar"){ fileset(dir:"build/classes"){ exclude(name:"*.*") From 92c856e1c0c4147d0135b5b5db2bc45d4895e5ab Mon Sep 17 00:00:00 2001 From: daniel Date: Tue, 1 Aug 2017 15:48:17 +0800 Subject: [PATCH 06/22] revert --- build.performance.gradle | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/build.performance.gradle b/build.performance.gradle index 1efdd55cc..102205679 100644 --- a/build.performance.gradle +++ b/build.performance.gradle @@ -3,32 +3,22 @@ tasks.withType(JavaCompile){ options.encoding = "UTF-8" } -def basicDir="../../" -def libDir="${basicDir}/finereport-lib-stable" -//获取什么分支名 -FileTree files =fileTree(dir:"./",include:"build.*.gradle") -def buildDir=files[0].path.substring(0,files[0].path.lastIndexOf ("\\")) -def branchName=buildDir.substring(buildDir.lastIndexOf ("\\")+1) +def basicDir="../" +def libDir="${basicDir}/lib" task appletJar<<{ - ant{ mkdir(dir:"./tmp") - mkdir(dir:"build/classes/") + mkdir(dir:"build/classes/main") copy(todir:"build/classes/"){ - fileset(dir:"${basicDir}/finereport-core-stable/${branchName}/build/classes/main") - - fileset(dir:"${basicDir}/finereport-chart-stable/${branchName}/build/classes/main") - - fileset(dir:"${basicDir}/finereport-report-stable/${branchName}/build/classes/main") - - fileset(dir:"${basicDir}/finereport-platform-stable/${branchName}/build/classes/main") - - fileset(dir:"${basicDir}/finereport-performance-stable/${branchName}/build/classes/main") - + fileset(dir:"${basicDir}/core/build/classes/main") + fileset(dir:"${basicDir}/chart/build/classes/main") + fileset(dir:"${basicDir}/report/build/classes/main") + fileset(dir:"${basicDir}/platform/build/classes/main") + fileset(dir:"${basicDir}/performance/build/classes/main") } - unjar(src:"${libDir}/${branchName}/3rd.jar",dest:"./tmp") - unjar(src:"${libDir}/${branchName}/servlet-api.jar",dest:"./tmp") + unjar(src:"${libDir}/3rd.jar",dest:"./tmp") + unjar(src:"${libDir}/servlet-api.jar",dest:"./tmp") jar(jarfile:"build/libs/fr-applet-8.0.jar"){ fileset(dir:"build/classes"){ exclude(name:"*.*") From 0144fe22e0522f091b65c52621d71cfd03c65c6a Mon Sep 17 00:00:00 2001 From: daniel Date: Tue, 1 Aug 2017 15:50:33 +0800 Subject: [PATCH 07/22] =?UTF-8?q?=E6=89=93=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.performance.gradle | 1 - 1 file changed, 1 deletion(-) diff --git a/build.performance.gradle b/build.performance.gradle index 102205679..fe011898f 100644 --- a/build.performance.gradle +++ b/build.performance.gradle @@ -15,7 +15,6 @@ task appletJar<<{ fileset(dir:"${basicDir}/chart/build/classes/main") fileset(dir:"${basicDir}/report/build/classes/main") fileset(dir:"${basicDir}/platform/build/classes/main") - fileset(dir:"${basicDir}/performance/build/classes/main") } unjar(src:"${libDir}/3rd.jar",dest:"./tmp") unjar(src:"${libDir}/servlet-api.jar",dest:"./tmp") From 90b3de2fcfc5da170e08ad96339a73fd90bd8aa0 Mon Sep 17 00:00:00 2001 From: plough Date: Fri, 4 Aug 2017 09:31:17 +0800 Subject: [PATCH 08/22] =?UTF-8?q?=E6=97=A0JIRA=E4=BB=BB=E5=8A=A1=EF=BC=8C?= =?UTF-8?q?=E4=B8=8D=E5=BD=B1=E5=93=8D=E6=A8=A1=E6=9D=BF=E6=AD=A3=E5=B8=B8?= =?UTF-8?q?=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer_base/src/com/fr/design/mainframe/JTemplate.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/designer_base/src/com/fr/design/mainframe/JTemplate.java b/designer_base/src/com/fr/design/mainframe/JTemplate.java index a275d3d5d..28d71f988 100644 --- a/designer_base/src/com/fr/design/mainframe/JTemplate.java +++ b/designer_base/src/com/fr/design/mainframe/JTemplate.java @@ -121,7 +121,10 @@ public abstract class JTemplate> ex return; } long saveTime = System.currentTimeMillis(); // 保存模板的时间点 - tic.collectInfo(template, this, openTime, saveTime); + try { + tic.collectInfo(template, this, openTime, saveTime); + } catch (Throwable th) { // 不管收集过程中出现任何异常,都不应该影响模版保存 + } openTime = saveTime; // 更新 openTime,准备下一次计算 } From 8c73bc8175a640e17d2e241c10a7ecd5a43559e4 Mon Sep 17 00:00:00 2001 From: zhouping Date: Tue, 8 Aug 2017 20:27:02 +0800 Subject: [PATCH 09/22] =?UTF-8?q?REPORT-2975=209.0=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E5=8D=87=E7=BA=A7=20UILabel=E5=8A=A0=E4=B8=AA=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E4=B8=8D=E5=8F=AF=E7=94=A8=E7=9A=84=E6=9E=84=E9=80=A0?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer_base/src/com/fr/design/gui/ilable/UILabel.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/designer_base/src/com/fr/design/gui/ilable/UILabel.java b/designer_base/src/com/fr/design/gui/ilable/UILabel.java index b1c90d8ff..c0b921dee 100644 --- a/designer_base/src/com/fr/design/gui/ilable/UILabel.java +++ b/designer_base/src/com/fr/design/gui/ilable/UILabel.java @@ -29,6 +29,11 @@ public class UILabel extends JLabel { super(text); } + public UILabel(String text, boolean enable) { + super(text); + this.setEnabled(enable); + } + public UILabel(Icon image, int horizontalAlignment) { super(image, horizontalAlignment); } From e13f1187f46dc3491677956b106ce8ee63f5bd40 Mon Sep 17 00:00:00 2001 From: daniel Date: Thu, 24 Aug 2017 11:38:27 +0800 Subject: [PATCH 10/22] =?UTF-8?q?=E6=97=A0JIAR=E4=BB=BB=E5=8A=A1=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/data/DesignTableDataManager.java | 7 ++--- .../mainframe/loghandler/LogHandlerBar.java | 26 +------------------ 2 files changed, 5 insertions(+), 28 deletions(-) diff --git a/designer_base/src/com/fr/design/data/DesignTableDataManager.java b/designer_base/src/com/fr/design/data/DesignTableDataManager.java index 621e303b1..5248c9626 100644 --- a/designer_base/src/com/fr/design/data/DesignTableDataManager.java +++ b/designer_base/src/com/fr/design/data/DesignTableDataManager.java @@ -36,6 +36,7 @@ import java.io.ByteArrayOutputStream; import java.text.Collator; import java.util.*; import java.util.Map.Entry; +import java.util.concurrent.ConcurrentHashMap; /** * 设计器管理操作数据集的类: @@ -54,11 +55,11 @@ public abstract class DesignTableDataManager { * 其实globalDsCache没有绝对的必要,只是为了操作方便。如果没有它,那么每次清空服务器数据集或者存储过程的时候,还要去遍历找一下, * 这个操作可能比较复杂 。 从减少代码复杂度的角度看,还是很有必要的 */ - private static java.util.Map globalDsCache = new java.util.HashMap(); - private static java.util.Map dsNameChangedMap = new HashMap(); + private static java.util.Map globalDsCache = new ConcurrentHashMap(); + private static java.util.Map dsNameChangedMap = new ConcurrentHashMap(); // private static List dsListeners = new ArrayList(); - private static Map> dsListenersMap = new HashMap>(); + private static Map> dsListenersMap = new ConcurrentHashMap>();; public static String NO_PARAMETER = "no_paramater_pane"; diff --git a/designer_base/src/com/fr/design/mainframe/loghandler/LogHandlerBar.java b/designer_base/src/com/fr/design/mainframe/loghandler/LogHandlerBar.java index eeba6c2fd..9b33b3c11 100644 --- a/designer_base/src/com/fr/design/mainframe/loghandler/LogHandlerBar.java +++ b/designer_base/src/com/fr/design/mainframe/loghandler/LogHandlerBar.java @@ -33,8 +33,6 @@ public class LogHandlerBar extends JPanel implements ItemSelectable { private int SERVERNUM = 0; private boolean isWithSerious; - private int i; - private Timer timer; public LogHandlerBar() { this(null); @@ -95,29 +93,7 @@ public class LogHandlerBar extends JPanel implements ItemSelectable { } public synchronized void timerPaint() { - isWithSerious = true; - timer = new Timer(500, null); - ActionListener taskAction = new ActionListener() { - public void actionPerformed(ActionEvent e) { - if (i < 5) { - isWithSerious = i % 2 == 0 ? true : false; - repaint(); - } else if (i == 5) { - if (timer == null) - return; - timer.stop(); - timer = null; - i = 0; - isWithSerious = true; - return; - } - i++; - } - }; - if (timer != null) { - timer.addActionListener(taskAction); - timer.start(); - } + repaint(); } public int getInfo() { From ee3fb9697eb2615f6fbea57750d0804b786d3e4b Mon Sep 17 00:00:00 2001 From: mengao <283296419@qq.com> Date: Fri, 1 Sep 2017 10:30:42 +0800 Subject: [PATCH 11/22] =?UTF-8?q?=E5=8E=BB=E6=8E=89ChartEditPane=E5=AF=B9P?= =?UTF-8?q?repare4DataSourceChange=E6=8E=A5=E5=8F=A3=E7=9A=84=E5=AE=9E?= =?UTF-8?q?=E7=8E=B0=E3=80=82=20=E8=A7=A3=E5=86=B3=20=20=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E5=88=87=E6=8D=A2=E6=A8=A1=E6=9D=BF=E6=97=B6=E4=B8=80?= =?UTF-8?q?=E7=9B=B4=E8=A7=A6=E5=8F=91=E6=9F=A5=E8=AF=A2=20=20=20=E5=AE=A2?= =?UTF-8?q?=E6=88=B7bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/mainframe/chart/ChartEditPane.java | 62 ++++++++----------- 1 file changed, 26 insertions(+), 36 deletions(-) diff --git a/designer_chart/src/com/fr/design/mainframe/chart/ChartEditPane.java b/designer_chart/src/com/fr/design/mainframe/chart/ChartEditPane.java index fc3b70108..3397fe9f9 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/ChartEditPane.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/ChartEditPane.java @@ -6,8 +6,6 @@ import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.ChartCollection; import com.fr.design.ChartTypeInterfaceManager; import com.fr.design.beans.FurtherBasicBeanPane; -import com.fr.design.data.DesignTableDataManager; -import com.fr.design.data.tabledata.Prepare4DataSourceChange; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.chart.ChartEditPaneProvider; import com.fr.design.gui.frpane.AttributeChangeListener; @@ -24,14 +22,12 @@ import com.fr.general.FRLogger; import com.fr.general.Inter; import javax.swing.*; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; import java.awt.*; import java.util.ArrayList; import java.util.Calendar; import java.util.List; -public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4DataSourceChange, ChartEditPaneProvider { +public class ChartEditPane extends BasicPane implements AttributeChange, ChartEditPaneProvider { private final static int CHANGE_MIN_TIME = 80; @@ -69,7 +65,9 @@ public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4 paneList.add(otherPane); createTabsPane(); - registerDSChangeListener(); + + //TableDataComboBox 中有注册DSChangeListener,这里没有必要再次注册。 + //registerDSChangeListener(); } //构建主面板 @@ -119,7 +117,7 @@ public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4 } catch (CloneNotSupportedException e) { FRLogger.getLogger().error("error in clone ChartEditPane"); } - if(ComparatorUtils.equals(selectedPane.title4PopupWindow(),PaneTitleConstants.CHART_STYLE_TITLE)){ + if (ComparatorUtils.equals(selectedPane.title4PopupWindow(), PaneTitleConstants.CHART_STYLE_TITLE)) { dealWithStyleChange(); } @@ -130,10 +128,11 @@ public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4 /** * 重新构造面板 + * * @param currentChart 图表 */ - public void reLayout(Chart currentChart){ - if(currentChart != null){ + public void reLayout(Chart currentChart) { + if (currentChart != null) { int chartIndex = getSelectedChartIndex(currentChart); this.removeAll(); this.setLayout(new BorderLayout()); @@ -142,21 +141,21 @@ public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4 boolean isDefault = true; String plotID = ""; - if(currentChart.getPlot() != null){ + if (currentChart.getPlot() != null) { plotID = currentChart.getPlot().getPlotID(); isDefault = ChartTypeInterfaceManager.getInstance().isUseDefaultPane(plotID); } - if(isDefault){ + if (isDefault) { paneList.add(dataPane4SupportCell); paneList.add(stylePane); paneList.add(otherPane); this.isDefaultPane = true; - }else{ + } else { ChartDataPane chartDataPane = createChartDataPane(plotID); paneList.add(chartDataPane); AbstractChartAttrPane[] otherPaneList = ChartTypeInterfaceManager.getInstance().getAttrPaneArray(plotID, listener); - for(int i = 0; i < otherPaneList.length; i++){ + for (int i = 0; i < otherPaneList.length; i++) { otherPaneList[i].addAttributeChangeListener(listener); paneList.add(otherPaneList[i]); } @@ -223,7 +222,7 @@ public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4 return; } - if(checkNeedsReLayout(collection.getSelectedChart())){ + if (checkNeedsReLayout(collection.getSelectedChart())) { reLayout(collection.getSelectedChart()); } @@ -250,12 +249,12 @@ public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4 } } - public int getSelectedChartIndex(Chart chart){ + public int getSelectedChartIndex(Chart chart) { int index = 0; - if(typePane != null){ + if (typePane != null) { FurtherBasicBeanPane[] paneList = typePane.getPaneList(); - for(; index < paneList.length; index++){ - if(paneList[index].accept(chart)){ + for (; index < paneList.length; index++) { + if (paneList[index].accept(chart)) { return index; } } @@ -264,12 +263,12 @@ public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4 } //populate的时候看看要不要重构面板 - private boolean checkNeedsReLayout(Chart chart){ - if(chart != null){ + private boolean checkNeedsReLayout(Chart chart) { + if (chart != null) { int lastIndex = typePane.getSelectedIndex(); int currentIndex = getSelectedChartIndex(chart); boolean currentPane = true; - if(chart.getPlot() != null){ + if (chart.getPlot() != null) { String plotID = chart.getPlot().getPlotID(); currentPane = ChartTypeInterfaceManager.getInstance().isUseDefaultPane(plotID); } @@ -280,9 +279,10 @@ public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4 /** * 当前界面是否是默认的界面 + * * @return 是否是默认的界面 */ - public boolean isDefaultPane(){ + public boolean isDefaultPane() { return this.isDefaultPane; } @@ -314,15 +314,16 @@ public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4 } } - protected void dealWithStyleChange(){ + protected void dealWithStyleChange() { } /** - *主要用于图表设计器,判断样式改变是否来自工具栏的全局样式按钮 + * 主要用于图表设计器,判断样式改变是否来自工具栏的全局样式按钮 + * * @param isFromToolBar 是否来自工具栏 */ - public void styleChange(boolean isFromToolBar){ + public void styleChange(boolean isFromToolBar) { } @@ -335,15 +336,4 @@ public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4 paneList.get(index).addAttributeChangeListener(listener); } - /** - * 数据集改变的事件监听 - */ - public void registerDSChangeListener() { - DesignTableDataManager.addDsChangeListener(new ChangeListener() { - public void stateChanged(ChangeEvent e) { - AbstractChartAttrPane attrPane = paneList.get(tabsHeaderIconPane.getSelectedIndex()); - attrPane.refreshChartDataPane(collection); - } - }); - } } \ No newline at end of file From 0c79b531631a51954882f5410faf20aab89f5a46 Mon Sep 17 00:00:00 2001 From: plough Date: Mon, 4 Sep 2017 14:19:43 +0800 Subject: [PATCH 12/22] =?UTF-8?q?REPORT-4296=20frm=E6=8E=A7=E4=BB=B6?= =?UTF-8?q?=E6=A0=8F=E6=97=A0=E6=B3=95=E6=AD=A3=E5=B8=B8=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E5=9B=BE=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/design/mainframe/FormParaWidgetPane.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/designer_form/src/com/fr/design/mainframe/FormParaWidgetPane.java b/designer_form/src/com/fr/design/mainframe/FormParaWidgetPane.java index 929e10110..bfc7406de 100644 --- a/designer_form/src/com/fr/design/mainframe/FormParaWidgetPane.java +++ b/designer_form/src/com/fr/design/mainframe/FormParaWidgetPane.java @@ -286,7 +286,9 @@ public class FormParaWidgetPane extends JPanel { private int calculateWidgetWindowRowNum() { //向上取整 - int rowNum = (int) Math.ceil((double) predifinedwidgeList.size() / (double) preWidgetShowMaxNum); + int eastRowNum = (int) Math.ceil((double) predifinedwidgeList.size() / (double) preWidgetShowMaxNum); + int westRowNum = (int) Math.ceil((double) loadWidgetOptions().length / (double) commonWidgetNum); + int rowNum = Math.max(eastRowNum, westRowNum); rowNum = Math.max(rowNum, 2); rowNum = Math.min(rowNum, preWidgetShowMaxRow); return rowNum; From db3afdf2838ff3236950c9b7189d1e8e50aafa5e Mon Sep 17 00:00:00 2001 From: MoMeak Date: Mon, 4 Sep 2017 15:42:35 +0800 Subject: [PATCH 13/22] =?UTF-8?q?REPORT-4345=20=E8=AE=BE=E7=BD=AE=E4=BA=86?= =?UTF-8?q?=E8=BF=87=E6=BB=A4=E7=9A=84=E5=8D=95=E5=85=83=E6=A0=BC=E4=B8=8B?= =?UTF-8?q?=E6=8B=89=E5=A4=8D=E5=88=B6=E5=90=8E=EF=BC=8C=E5=9C=A8=E5=8F=B3?= =?UTF-8?q?=E4=BE=A7=E9=9D=A2=E6=9D=BF=E7=BB=99=E5=85=B6=E4=B8=AD=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E5=8D=95=E5=85=83=E6=A0=BC=E6=9B=B4=E6=94=B9=E8=BF=87?= =?UTF-8?q?=E6=BB=A4=E8=AE=BE=E7=BD=AE=EF=BC=8C=E5=88=99=E6=89=80=E6=9C=89?= =?UTF-8?q?=E5=8D=95=E5=85=83=E6=A0=BC=E7=9A=84=E8=BF=87=E6=BB=A4=E9=83=BD?= =?UTF-8?q?=E4=BC=9A=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer/src/com/fr/grid/IntelliElements.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/designer/src/com/fr/grid/IntelliElements.java b/designer/src/com/fr/grid/IntelliElements.java index 475235e56..a5d805563 100644 --- a/designer/src/com/fr/grid/IntelliElements.java +++ b/designer/src/com/fr/grid/IntelliElements.java @@ -194,7 +194,12 @@ public class IntelliElements { TemplateCellElement newCellElement = new DefaultTemplateCellElement(colIndex, rowIndex); applyStyle(newCellElement, sourceCellElement);//style if (sourceCellElement.getValue() instanceof DSColumn) { - DSColumn dsColumn = (DSColumn) sourceCellElement.getValue(); + DSColumn dsColumn = null; + try { + dsColumn = (DSColumn) ((DSColumn) sourceCellElement.getValue()).clone(); + } catch (CloneNotSupportedException e) { + FRContext.getLogger().error(e.getMessage(), e); + } newCellElement.setValue(dsColumn); newCellElement.setCellExpandAttr(sourceCellElement.getCellExpandAttr()); } else if (sourceCellElement.getValue() instanceof Number) { From 4124ad704b8f230b13cc9814eb35916e01396ffc Mon Sep 17 00:00:00 2001 From: mengao <283296419@qq.com> Date: Tue, 5 Sep 2017 17:40:22 +0800 Subject: [PATCH 14/22] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=80=E7=9B=B4?= =?UTF-8?q?=E8=A7=A6=E5=8F=91=E6=9F=A5=E8=AF=A2bug=EF=BC=8C=E6=95=B4?= =?UTF-8?q?=E7=90=86chartEditPane=E5=8A=A0=E8=BD=BD=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fun/impl/AbstractIndependentChartUI.java | 3 +- ...bstractIndependentChartUIWithAPILevel.java | 3 +- .../fun/impl/AbstractIndependentChartsUI.java | 2 +- .../design/mainframe/ChartPropertyPane.java | 8 ++- .../mainframe/MiddleChartPropertyPane.java | 6 +- .../design/mainframe/chart/ChartEditPane.java | 71 ++++++++++++------- .../mainframe/chart/ChartsEditPane.java | 9 +++ 7 files changed, 64 insertions(+), 38 deletions(-) diff --git a/designer_chart/src/com/fr/design/chart/fun/impl/AbstractIndependentChartUI.java b/designer_chart/src/com/fr/design/chart/fun/impl/AbstractIndependentChartUI.java index 848fc4436..b5cd25a7f 100644 --- a/designer_chart/src/com/fr/design/chart/fun/impl/AbstractIndependentChartUI.java +++ b/designer_chart/src/com/fr/design/chart/fun/impl/AbstractIndependentChartUI.java @@ -12,7 +12,6 @@ import com.fr.design.mainframe.chart.ChartsConfigPane; import com.fr.design.mainframe.chart.gui.ChartDataPane; import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.general.ComparatorUtils; -import com.fr.stable.StableUtils; /** @@ -58,7 +57,7 @@ public abstract class AbstractIndependentChartUI implements IndependentChartUIPr return new DataSeriesConditionPane(); } - public ChartEditPane getChartEditPane(String plotID){ return StableUtils.construct(ChartEditPane.class);} + public ChartEditPane getChartEditPane(String plotID){ return ChartEditPane.getInstance();} public ChartsConfigPane getChartConfigPane(String plotID){return null;} diff --git a/designer_chart/src/com/fr/design/chart/fun/impl/AbstractIndependentChartUIWithAPILevel.java b/designer_chart/src/com/fr/design/chart/fun/impl/AbstractIndependentChartUIWithAPILevel.java index 8aa412a6e..cd8dbdcfc 100644 --- a/designer_chart/src/com/fr/design/chart/fun/impl/AbstractIndependentChartUIWithAPILevel.java +++ b/designer_chart/src/com/fr/design/chart/fun/impl/AbstractIndependentChartUIWithAPILevel.java @@ -12,7 +12,6 @@ import com.fr.design.mainframe.chart.ChartsConfigPane; import com.fr.design.mainframe.chart.gui.ChartDataPane; import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.general.ComparatorUtils; -import com.fr.stable.StableUtils; /** * Created by Mitisky on 16/3/7. @@ -69,7 +68,7 @@ public abstract class AbstractIndependentChartUIWithAPILevel implements Independ return getPlotTypePane().title4PopupWindow(); } - public ChartEditPane getChartEditPane(String plotID){ return StableUtils.construct(ChartEditPane.class);} + public ChartEditPane getChartEditPane(String plotID){ return ChartEditPane.getInstance();} public ChartsConfigPane getChartConfigPane(String plotID){return null;} } diff --git a/designer_chart/src/com/fr/design/chart/fun/impl/AbstractIndependentChartsUI.java b/designer_chart/src/com/fr/design/chart/fun/impl/AbstractIndependentChartsUI.java index fbd3ce36f..703852c20 100644 --- a/designer_chart/src/com/fr/design/chart/fun/impl/AbstractIndependentChartsUI.java +++ b/designer_chart/src/com/fr/design/chart/fun/impl/AbstractIndependentChartsUI.java @@ -97,7 +97,7 @@ public abstract class AbstractIndependentChartsUI extends AbstractProvider imple @Override public ChartEditPane getChartEditPane(String plotID) { - return new ChartsEditPane(); + return ChartsEditPane.getInstance(); } } \ No newline at end of file diff --git a/designer_chart/src/com/fr/design/mainframe/ChartPropertyPane.java b/designer_chart/src/com/fr/design/mainframe/ChartPropertyPane.java index f29efe7af..64e2c0f79 100644 --- a/designer_chart/src/com/fr/design/mainframe/ChartPropertyPane.java +++ b/designer_chart/src/com/fr/design/mainframe/ChartPropertyPane.java @@ -14,9 +14,10 @@ public class ChartPropertyPane extends MiddleChartPropertyPane{ * 创建图表属性表实例. */ private synchronized static ChartPropertyPane getInstance() { - //todo //创建新图表时,创建属性表配置面板 - singleton = new ChartPropertyPane(); + if (singleton == null) { + singleton = new ChartPropertyPane(); + } return singleton; } @@ -36,6 +37,9 @@ public class ChartPropertyPane extends MiddleChartPropertyPane{ @Override protected void createMainPane() { + this.removeAll(); + createNameLabel(); + this.add(createNorthComponent(), BorderLayout.NORTH); this.add(chartEditPane, BorderLayout.CENTER); } diff --git a/designer_chart/src/com/fr/design/mainframe/MiddleChartPropertyPane.java b/designer_chart/src/com/fr/design/mainframe/MiddleChartPropertyPane.java index 1d9732205..5548e1ba7 100644 --- a/designer_chart/src/com/fr/design/mainframe/MiddleChartPropertyPane.java +++ b/designer_chart/src/com/fr/design/mainframe/MiddleChartPropertyPane.java @@ -15,7 +15,6 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itabpane.TitleChangeListener; import com.fr.design.mainframe.chart.ChartEditPane; import com.fr.general.Inter; -import com.fr.stable.StableUtils; import javax.swing.*; import java.awt.*; @@ -34,10 +33,7 @@ public abstract class MiddleChartPropertyPane extends BaseChartPropertyPane{ protected void initComponenet() { this.setLayout(new BorderLayout()); this.setBorder(null); - - createNameLabel(); - this.add(createNorthComponent(), BorderLayout.NORTH); - chartEditPane = StableUtils.construct(ChartEditPane.class); + chartEditPane = ChartEditPane.getInstance(); chartEditPane.setSupportCellData(true); } diff --git a/designer_chart/src/com/fr/design/mainframe/chart/ChartEditPane.java b/designer_chart/src/com/fr/design/mainframe/chart/ChartEditPane.java index 3397fe9f9..5784293d1 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/ChartEditPane.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/ChartEditPane.java @@ -6,6 +6,8 @@ import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.ChartCollection; import com.fr.design.ChartTypeInterfaceManager; import com.fr.design.beans.FurtherBasicBeanPane; +import com.fr.design.data.DesignTableDataManager; +import com.fr.design.data.tabledata.Prepare4DataSourceChange; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.chart.ChartEditPaneProvider; import com.fr.design.gui.frpane.AttributeChangeListener; @@ -22,12 +24,23 @@ import com.fr.general.FRLogger; import com.fr.general.Inter; import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; import java.awt.*; import java.util.ArrayList; import java.util.Calendar; import java.util.List; -public class ChartEditPane extends BasicPane implements AttributeChange, ChartEditPaneProvider { +public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4DataSourceChange, ChartEditPaneProvider { + + public synchronized static ChartEditPane getInstance() { + if (singleton == null) { + singleton = new ChartEditPane(); + } + return singleton; + } + + private static ChartEditPane singleton; private final static int CHANGE_MIN_TIME = 80; @@ -65,9 +78,7 @@ public class ChartEditPane extends BasicPane implements AttributeChange, ChartEd paneList.add(otherPane); createTabsPane(); - - //TableDataComboBox 中有注册DSChangeListener,这里没有必要再次注册。 - //registerDSChangeListener(); + registerDSChangeListener(); } //构建主面板 @@ -117,7 +128,7 @@ public class ChartEditPane extends BasicPane implements AttributeChange, ChartEd } catch (CloneNotSupportedException e) { FRLogger.getLogger().error("error in clone ChartEditPane"); } - if (ComparatorUtils.equals(selectedPane.title4PopupWindow(), PaneTitleConstants.CHART_STYLE_TITLE)) { + if(ComparatorUtils.equals(selectedPane.title4PopupWindow(),PaneTitleConstants.CHART_STYLE_TITLE)){ dealWithStyleChange(); } @@ -128,11 +139,10 @@ public class ChartEditPane extends BasicPane implements AttributeChange, ChartEd /** * 重新构造面板 - * * @param currentChart 图表 */ - public void reLayout(Chart currentChart) { - if (currentChart != null) { + public void reLayout(Chart currentChart){ + if(currentChart != null){ int chartIndex = getSelectedChartIndex(currentChart); this.removeAll(); this.setLayout(new BorderLayout()); @@ -141,21 +151,21 @@ public class ChartEditPane extends BasicPane implements AttributeChange, ChartEd boolean isDefault = true; String plotID = ""; - if (currentChart.getPlot() != null) { + if(currentChart.getPlot() != null){ plotID = currentChart.getPlot().getPlotID(); isDefault = ChartTypeInterfaceManager.getInstance().isUseDefaultPane(plotID); } - if (isDefault) { + if(isDefault){ paneList.add(dataPane4SupportCell); paneList.add(stylePane); paneList.add(otherPane); this.isDefaultPane = true; - } else { + }else{ ChartDataPane chartDataPane = createChartDataPane(plotID); paneList.add(chartDataPane); AbstractChartAttrPane[] otherPaneList = ChartTypeInterfaceManager.getInstance().getAttrPaneArray(plotID, listener); - for (int i = 0; i < otherPaneList.length; i++) { + for(int i = 0; i < otherPaneList.length; i++){ otherPaneList[i].addAttributeChangeListener(listener); paneList.add(otherPaneList[i]); } @@ -222,7 +232,7 @@ public class ChartEditPane extends BasicPane implements AttributeChange, ChartEd return; } - if (checkNeedsReLayout(collection.getSelectedChart())) { + if(checkNeedsReLayout(collection.getSelectedChart())){ reLayout(collection.getSelectedChart()); } @@ -249,12 +259,12 @@ public class ChartEditPane extends BasicPane implements AttributeChange, ChartEd } } - public int getSelectedChartIndex(Chart chart) { + public int getSelectedChartIndex(Chart chart){ int index = 0; - if (typePane != null) { + if(typePane != null){ FurtherBasicBeanPane[] paneList = typePane.getPaneList(); - for (; index < paneList.length; index++) { - if (paneList[index].accept(chart)) { + for(; index < paneList.length; index++){ + if(paneList[index].accept(chart)){ return index; } } @@ -263,12 +273,12 @@ public class ChartEditPane extends BasicPane implements AttributeChange, ChartEd } //populate的时候看看要不要重构面板 - private boolean checkNeedsReLayout(Chart chart) { - if (chart != null) { + private boolean checkNeedsReLayout(Chart chart){ + if(chart != null){ int lastIndex = typePane.getSelectedIndex(); int currentIndex = getSelectedChartIndex(chart); boolean currentPane = true; - if (chart.getPlot() != null) { + if(chart.getPlot() != null){ String plotID = chart.getPlot().getPlotID(); currentPane = ChartTypeInterfaceManager.getInstance().isUseDefaultPane(plotID); } @@ -279,10 +289,9 @@ public class ChartEditPane extends BasicPane implements AttributeChange, ChartEd /** * 当前界面是否是默认的界面 - * * @return 是否是默认的界面 */ - public boolean isDefaultPane() { + public boolean isDefaultPane(){ return this.isDefaultPane; } @@ -314,16 +323,15 @@ public class ChartEditPane extends BasicPane implements AttributeChange, ChartEd } } - protected void dealWithStyleChange() { + protected void dealWithStyleChange(){ } /** - * 主要用于图表设计器,判断样式改变是否来自工具栏的全局样式按钮 - * + *主要用于图表设计器,判断样式改变是否来自工具栏的全局样式按钮 * @param isFromToolBar 是否来自工具栏 */ - public void styleChange(boolean isFromToolBar) { + public void styleChange(boolean isFromToolBar){ } @@ -336,4 +344,15 @@ public class ChartEditPane extends BasicPane implements AttributeChange, ChartEd paneList.get(index).addAttributeChangeListener(listener); } + /** + * 数据集改变的事件监听 + */ + public void registerDSChangeListener() { + DesignTableDataManager.addDsChangeListener(new ChangeListener() { + public void stateChanged(ChangeEvent e) { + AbstractChartAttrPane attrPane = paneList.get(tabsHeaderIconPane.getSelectedIndex()); + attrPane.refreshChartDataPane(collection); + } + }); + } } \ No newline at end of file diff --git a/designer_chart/src/com/fr/design/mainframe/chart/ChartsEditPane.java b/designer_chart/src/com/fr/design/mainframe/chart/ChartsEditPane.java index 3f35c585d..87873cfd8 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/ChartsEditPane.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/ChartsEditPane.java @@ -13,6 +13,15 @@ import java.util.ArrayList; public class ChartsEditPane extends ChartEditPane { protected ChartsConfigPane chartsConfigPane; + private static ChartEditPane single; + + public synchronized static ChartEditPane getInstance() { + if (single == null) { + single = new ChartsEditPane(); + } + return single; + } + public ChartsEditPane() { this.setLayout(new BorderLayout()); From f8cd4e13c5161888fd12066277551b915b07475f Mon Sep 17 00:00:00 2001 From: mengao <283296419@qq.com> Date: Tue, 5 Sep 2017 19:16:40 +0800 Subject: [PATCH 15/22] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=80=E7=9B=B4?= =?UTF-8?q?=E8=A7=A6=E5=8F=91=E6=9F=A5=E8=AF=A2bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fun/impl/AbstractIndependentChartUI.java | 3 +- ...bstractIndependentChartUIWithAPILevel.java | 3 +- .../fun/impl/AbstractIndependentChartsUI.java | 2 +- .../design/mainframe/ChartPropertyPane.java | 10 +--- .../mainframe/MiddleChartPropertyPane.java | 60 ++++++++++--------- .../design/mainframe/chart/ChartEditPane.java | 13 +--- .../mainframe/chart/ChartsEditPane.java | 9 --- 7 files changed, 43 insertions(+), 57 deletions(-) diff --git a/designer_chart/src/com/fr/design/chart/fun/impl/AbstractIndependentChartUI.java b/designer_chart/src/com/fr/design/chart/fun/impl/AbstractIndependentChartUI.java index b5cd25a7f..848fc4436 100644 --- a/designer_chart/src/com/fr/design/chart/fun/impl/AbstractIndependentChartUI.java +++ b/designer_chart/src/com/fr/design/chart/fun/impl/AbstractIndependentChartUI.java @@ -12,6 +12,7 @@ import com.fr.design.mainframe.chart.ChartsConfigPane; import com.fr.design.mainframe.chart.gui.ChartDataPane; import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.general.ComparatorUtils; +import com.fr.stable.StableUtils; /** @@ -57,7 +58,7 @@ public abstract class AbstractIndependentChartUI implements IndependentChartUIPr return new DataSeriesConditionPane(); } - public ChartEditPane getChartEditPane(String plotID){ return ChartEditPane.getInstance();} + public ChartEditPane getChartEditPane(String plotID){ return StableUtils.construct(ChartEditPane.class);} public ChartsConfigPane getChartConfigPane(String plotID){return null;} diff --git a/designer_chart/src/com/fr/design/chart/fun/impl/AbstractIndependentChartUIWithAPILevel.java b/designer_chart/src/com/fr/design/chart/fun/impl/AbstractIndependentChartUIWithAPILevel.java index cd8dbdcfc..8aa412a6e 100644 --- a/designer_chart/src/com/fr/design/chart/fun/impl/AbstractIndependentChartUIWithAPILevel.java +++ b/designer_chart/src/com/fr/design/chart/fun/impl/AbstractIndependentChartUIWithAPILevel.java @@ -12,6 +12,7 @@ import com.fr.design.mainframe.chart.ChartsConfigPane; import com.fr.design.mainframe.chart.gui.ChartDataPane; import com.fr.design.mainframe.chart.gui.ChartStylePane; import com.fr.general.ComparatorUtils; +import com.fr.stable.StableUtils; /** * Created by Mitisky on 16/3/7. @@ -68,7 +69,7 @@ public abstract class AbstractIndependentChartUIWithAPILevel implements Independ return getPlotTypePane().title4PopupWindow(); } - public ChartEditPane getChartEditPane(String plotID){ return ChartEditPane.getInstance();} + public ChartEditPane getChartEditPane(String plotID){ return StableUtils.construct(ChartEditPane.class);} public ChartsConfigPane getChartConfigPane(String plotID){return null;} } diff --git a/designer_chart/src/com/fr/design/chart/fun/impl/AbstractIndependentChartsUI.java b/designer_chart/src/com/fr/design/chart/fun/impl/AbstractIndependentChartsUI.java index 703852c20..fbd3ce36f 100644 --- a/designer_chart/src/com/fr/design/chart/fun/impl/AbstractIndependentChartsUI.java +++ b/designer_chart/src/com/fr/design/chart/fun/impl/AbstractIndependentChartsUI.java @@ -97,7 +97,7 @@ public abstract class AbstractIndependentChartsUI extends AbstractProvider imple @Override public ChartEditPane getChartEditPane(String plotID) { - return ChartsEditPane.getInstance(); + return new ChartsEditPane(); } } \ No newline at end of file diff --git a/designer_chart/src/com/fr/design/mainframe/ChartPropertyPane.java b/designer_chart/src/com/fr/design/mainframe/ChartPropertyPane.java index 64e2c0f79..868fefbf7 100644 --- a/designer_chart/src/com/fr/design/mainframe/ChartPropertyPane.java +++ b/designer_chart/src/com/fr/design/mainframe/ChartPropertyPane.java @@ -14,10 +14,9 @@ public class ChartPropertyPane extends MiddleChartPropertyPane{ * 创建图表属性表实例. */ private synchronized static ChartPropertyPane getInstance() { + //todo //创建新图表时,创建属性表配置面板 - if (singleton == null) { - singleton = new ChartPropertyPane(); - } + singleton = new ChartPropertyPane(); return singleton; } @@ -31,15 +30,12 @@ public class ChartPropertyPane extends MiddleChartPropertyPane{ return new Dimension(super.getPreferredSize().width, 18); } }; - nameLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 1, 0)); + nameLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 1, 0)); nameLabel.setHorizontalAlignment(SwingConstants.CENTER); } @Override protected void createMainPane() { - this.removeAll(); - createNameLabel(); - this.add(createNorthComponent(), BorderLayout.NORTH); this.add(chartEditPane, BorderLayout.CENTER); } diff --git a/designer_chart/src/com/fr/design/mainframe/MiddleChartPropertyPane.java b/designer_chart/src/com/fr/design/mainframe/MiddleChartPropertyPane.java index 5548e1ba7..4ddd8740c 100644 --- a/designer_chart/src/com/fr/design/mainframe/MiddleChartPropertyPane.java +++ b/designer_chart/src/com/fr/design/mainframe/MiddleChartPropertyPane.java @@ -15,6 +15,7 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itabpane.TitleChangeListener; import com.fr.design.mainframe.chart.ChartEditPane; import com.fr.general.Inter; +import com.fr.stable.StableUtils; import javax.swing.*; import java.awt.*; @@ -29,11 +30,14 @@ public abstract class MiddleChartPropertyPane extends BaseChartPropertyPane{ public MiddleChartPropertyPane() { initComponenet(); } - + protected void initComponenet() { this.setLayout(new BorderLayout()); this.setBorder(null); - chartEditPane = ChartEditPane.getInstance(); + + createNameLabel(); + this.add(createNorthComponent(), BorderLayout.NORTH); + chartEditPane = StableUtils.construct(ChartEditPane.class); chartEditPane.setSupportCellData(true); } @@ -43,11 +47,11 @@ public abstract class MiddleChartPropertyPane extends BaseChartPropertyPane{ this.createMainPane(); setSureProperty(); } - + protected abstract void createNameLabel(); - + protected abstract JComponent createNorthComponent(); - + protected abstract void createMainPane(); @@ -63,7 +67,7 @@ public abstract class MiddleChartPropertyPane extends BaseChartPropertyPane{ nameLabel.setText(Inter.getLocText("Chart-Property_Table") + (tabname != null ? ('-' + chartEditPane.getSelectedTabName()) : "")); resetChartEditPane(); } - + protected void resetChartEditPane() { remove(chartEditPane); add(chartEditPane, BorderLayout.CENTER); @@ -71,20 +75,20 @@ public abstract class MiddleChartPropertyPane extends BaseChartPropertyPane{ repaint(); revalidate(); } - + protected TitleChangeListener titleListener = new TitleChangeListener() { - + @Override public void fireTitleChange(String addName) { nameLabel.setText(Inter.getLocText("Chart-Property_Table") + '-' + addName); } }; - /** - * 感觉ChartCollection加载图表属性界面. - * @param collection 收集图表 - * @param ePane 面板 - */ + /** + * 感觉ChartCollection加载图表属性界面. + * @param collection 收集图表 + * @param ePane 面板 + */ public void populateChartPropertyPane(ChartCollection collection, TargetComponent ePane) { addChartEditPane(collection.getSelectedChart().getPlot().getPlotID()); setSupportCellData(true); @@ -92,11 +96,11 @@ public abstract class MiddleChartPropertyPane extends BaseChartPropertyPane{ chartEditPane.populate(collection); } - /** - * 感觉ChartCollection加载图表属性界面. - * @param collection 收集图表 - * @param ePane 面板 - */ + /** + * 感觉ChartCollection加载图表属性界面. + * @param collection 收集图表 + * @param ePane 面板 + */ public void populateChartPropertyPane(BaseChartCollection collection, TargetComponent ePane) { if (collection instanceof ChartCollection) { populateChartPropertyPane((ChartCollection)collection, ePane); @@ -123,18 +127,18 @@ public abstract class MiddleChartPropertyPane extends BaseChartPropertyPane{ return BaseUtils.readIcon("/com/fr/design/images/m_report/qb.png"); } - /** - * 预定义定位 - * @return 定位 - */ + /** + * 预定义定位 + * @return 定位 + */ public Location preferredLocation() { return Location.WEST_BELOW; } - /** - * 创建标题Panel - * @return 标题panel - */ + /** + * 创建标题Panel + * @return 标题panel + */ public UITitlePanel createTitlePanel() { return new UITitlePanel(this); } @@ -144,9 +148,9 @@ public abstract class MiddleChartPropertyPane extends BaseChartPropertyPane{ */ public void refreshDockingView() { // TODO Auto-generated method stub - + } - + /** * 设置是否支持单元格数据. */ diff --git a/designer_chart/src/com/fr/design/mainframe/chart/ChartEditPane.java b/designer_chart/src/com/fr/design/mainframe/chart/ChartEditPane.java index 5784293d1..fed9d2a82 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/ChartEditPane.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/ChartEditPane.java @@ -33,15 +33,6 @@ import java.util.List; public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4DataSourceChange, ChartEditPaneProvider { - public synchronized static ChartEditPane getInstance() { - if (singleton == null) { - singleton = new ChartEditPane(); - } - return singleton; - } - - private static ChartEditPane singleton; - private final static int CHANGE_MIN_TIME = 80; protected ChartCollection collection; @@ -351,7 +342,9 @@ public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4 DesignTableDataManager.addDsChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { AbstractChartAttrPane attrPane = paneList.get(tabsHeaderIconPane.getSelectedIndex()); - attrPane.refreshChartDataPane(collection); + if (attrPane.isShowing()) { + attrPane.refreshChartDataPane(collection); + } } }); } diff --git a/designer_chart/src/com/fr/design/mainframe/chart/ChartsEditPane.java b/designer_chart/src/com/fr/design/mainframe/chart/ChartsEditPane.java index 87873cfd8..3f35c585d 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/ChartsEditPane.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/ChartsEditPane.java @@ -13,15 +13,6 @@ import java.util.ArrayList; public class ChartsEditPane extends ChartEditPane { protected ChartsConfigPane chartsConfigPane; - private static ChartEditPane single; - - public synchronized static ChartEditPane getInstance() { - if (single == null) { - single = new ChartsEditPane(); - } - return single; - } - public ChartsEditPane() { this.setLayout(new BorderLayout()); From a2e131d0cfd164866e90ffcbd2a879a9be71062f Mon Sep 17 00:00:00 2001 From: mengao <283296419@qq.com> Date: Tue, 5 Sep 2017 19:17:49 +0800 Subject: [PATCH 16/22] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=80=E7=9B=B4?= =?UTF-8?q?=E8=A7=A6=E5=8F=91=E6=9F=A5=E8=AF=A2bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/design/mainframe/chart/ChartEditPane.java | 1 + 1 file changed, 1 insertion(+) diff --git a/designer_chart/src/com/fr/design/mainframe/chart/ChartEditPane.java b/designer_chart/src/com/fr/design/mainframe/chart/ChartEditPane.java index fed9d2a82..f141f092f 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/ChartEditPane.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/ChartEditPane.java @@ -342,6 +342,7 @@ public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4 DesignTableDataManager.addDsChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { AbstractChartAttrPane attrPane = paneList.get(tabsHeaderIconPane.getSelectedIndex()); + //不显示,没有处于编辑状态,没必要更新。 if (attrPane.isShowing()) { attrPane.refreshChartDataPane(collection); } From f4e5bf1ec6995afd5a01242eb1867911e4866f16 Mon Sep 17 00:00:00 2001 From: mengao <283296419@qq.com> Date: Tue, 5 Sep 2017 19:19:48 +0800 Subject: [PATCH 17/22] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E6=A3=80=E6=9F=A5=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/mainframe/chart/ChartEditPane.java | 43 ++++++++++--------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/designer_chart/src/com/fr/design/mainframe/chart/ChartEditPane.java b/designer_chart/src/com/fr/design/mainframe/chart/ChartEditPane.java index f141f092f..e66ac1da7 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/ChartEditPane.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/ChartEditPane.java @@ -31,7 +31,7 @@ import java.util.ArrayList; import java.util.Calendar; import java.util.List; -public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4DataSourceChange, ChartEditPaneProvider { +public class ChartEditPane extends BasicPane implements AttributeChange, Prepare4DataSourceChange, ChartEditPaneProvider { private final static int CHANGE_MIN_TIME = 80; @@ -119,7 +119,7 @@ public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4 } catch (CloneNotSupportedException e) { FRLogger.getLogger().error("error in clone ChartEditPane"); } - if(ComparatorUtils.equals(selectedPane.title4PopupWindow(),PaneTitleConstants.CHART_STYLE_TITLE)){ + if (ComparatorUtils.equals(selectedPane.title4PopupWindow(), PaneTitleConstants.CHART_STYLE_TITLE)) { dealWithStyleChange(); } @@ -130,10 +130,11 @@ public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4 /** * 重新构造面板 + * * @param currentChart 图表 */ - public void reLayout(Chart currentChart){ - if(currentChart != null){ + public void reLayout(Chart currentChart) { + if (currentChart != null) { int chartIndex = getSelectedChartIndex(currentChart); this.removeAll(); this.setLayout(new BorderLayout()); @@ -142,21 +143,21 @@ public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4 boolean isDefault = true; String plotID = ""; - if(currentChart.getPlot() != null){ + if (currentChart.getPlot() != null) { plotID = currentChart.getPlot().getPlotID(); isDefault = ChartTypeInterfaceManager.getInstance().isUseDefaultPane(plotID); } - if(isDefault){ + if (isDefault) { paneList.add(dataPane4SupportCell); paneList.add(stylePane); paneList.add(otherPane); this.isDefaultPane = true; - }else{ + } else { ChartDataPane chartDataPane = createChartDataPane(plotID); paneList.add(chartDataPane); AbstractChartAttrPane[] otherPaneList = ChartTypeInterfaceManager.getInstance().getAttrPaneArray(plotID, listener); - for(int i = 0; i < otherPaneList.length; i++){ + for (int i = 0; i < otherPaneList.length; i++) { otherPaneList[i].addAttributeChangeListener(listener); paneList.add(otherPaneList[i]); } @@ -223,7 +224,7 @@ public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4 return; } - if(checkNeedsReLayout(collection.getSelectedChart())){ + if (checkNeedsReLayout(collection.getSelectedChart())) { reLayout(collection.getSelectedChart()); } @@ -250,12 +251,12 @@ public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4 } } - public int getSelectedChartIndex(Chart chart){ + public int getSelectedChartIndex(Chart chart) { int index = 0; - if(typePane != null){ + if (typePane != null) { FurtherBasicBeanPane[] paneList = typePane.getPaneList(); - for(; index < paneList.length; index++){ - if(paneList[index].accept(chart)){ + for (; index < paneList.length; index++) { + if (paneList[index].accept(chart)) { return index; } } @@ -264,12 +265,12 @@ public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4 } //populate的时候看看要不要重构面板 - private boolean checkNeedsReLayout(Chart chart){ - if(chart != null){ + private boolean checkNeedsReLayout(Chart chart) { + if (chart != null) { int lastIndex = typePane.getSelectedIndex(); int currentIndex = getSelectedChartIndex(chart); boolean currentPane = true; - if(chart.getPlot() != null){ + if (chart.getPlot() != null) { String plotID = chart.getPlot().getPlotID(); currentPane = ChartTypeInterfaceManager.getInstance().isUseDefaultPane(plotID); } @@ -280,9 +281,10 @@ public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4 /** * 当前界面是否是默认的界面 + * * @return 是否是默认的界面 */ - public boolean isDefaultPane(){ + public boolean isDefaultPane() { return this.isDefaultPane; } @@ -314,15 +316,16 @@ public class ChartEditPane extends BasicPane implements AttributeChange,Prepare4 } } - protected void dealWithStyleChange(){ + protected void dealWithStyleChange() { } /** - *主要用于图表设计器,判断样式改变是否来自工具栏的全局样式按钮 + * 主要用于图表设计器,判断样式改变是否来自工具栏的全局样式按钮 + * * @param isFromToolBar 是否来自工具栏 */ - public void styleChange(boolean isFromToolBar){ + public void styleChange(boolean isFromToolBar) { } From ff3cd152cb4a5d06d42b917552f58db4d4f88d16 Mon Sep 17 00:00:00 2001 From: mengao <283296419@qq.com> Date: Tue, 5 Sep 2017 19:27:23 +0800 Subject: [PATCH 18/22] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E6=A3=80=E6=9F=A5=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/mainframe/MiddleChartPropertyPane.java | 5 +++-- .../com/fr/design/mainframe/chart/ChartEditPane.java | 12 +++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/designer_chart/src/com/fr/design/mainframe/MiddleChartPropertyPane.java b/designer_chart/src/com/fr/design/mainframe/MiddleChartPropertyPane.java index 4ddd8740c..53609b49d 100644 --- a/designer_chart/src/com/fr/design/mainframe/MiddleChartPropertyPane.java +++ b/designer_chart/src/com/fr/design/mainframe/MiddleChartPropertyPane.java @@ -16,6 +16,7 @@ import com.fr.design.gui.itabpane.TitleChangeListener; import com.fr.design.mainframe.chart.ChartEditPane; import com.fr.general.Inter; import com.fr.stable.StableUtils; +import com.fr.stable.StringUtils; import javax.swing.*; import java.awt.*; @@ -64,7 +65,7 @@ public abstract class MiddleChartPropertyPane extends BaseChartPropertyPane{ chartEditPane.setContainer(container); chartEditPane.addTitleChangeListener(titleListener); String tabname = chartEditPane.getSelectedTabName(); - nameLabel.setText(Inter.getLocText("Chart-Property_Table") + (tabname != null ? ('-' + chartEditPane.getSelectedTabName()) : "")); + nameLabel.setText(Inter.getLocText("Chart-Property_Table") + (tabname != null ? ('-' + chartEditPane.getSelectedTabName()) : StringUtils.EMPTY)); resetChartEditPane(); } @@ -155,7 +156,7 @@ public abstract class MiddleChartPropertyPane extends BaseChartPropertyPane{ * 设置是否支持单元格数据. */ public void setSupportCellData(boolean supportCellData) { - if(chartEditPane != null) { + if (chartEditPane != null) { chartEditPane.setSupportCellData(supportCellData); } } diff --git a/designer_chart/src/com/fr/design/mainframe/chart/ChartEditPane.java b/designer_chart/src/com/fr/design/mainframe/chart/ChartEditPane.java index e66ac1da7..f681f275e 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/ChartEditPane.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/ChartEditPane.java @@ -22,6 +22,7 @@ import com.fr.design.mainframe.chart.gui.ChartTypePane; import com.fr.general.ComparatorUtils; import com.fr.general.FRLogger; import com.fr.general.Inter; +import com.fr.stable.StringUtils; import javax.swing.*; import javax.swing.event.ChangeEvent; @@ -142,7 +143,7 @@ public class ChartEditPane extends BasicPane implements AttributeChange, Prepare addTypePane(); boolean isDefault = true; - String plotID = ""; + String plotID = StringUtils.EMPTY; if (currentChart.getPlot() != null) { plotID = currentChart.getPlot().getPlotID(); isDefault = ChartTypeInterfaceManager.getInstance().isUseDefaultPane(plotID); @@ -179,6 +180,7 @@ public class ChartEditPane extends BasicPane implements AttributeChange, Prepare } protected void setSelectedTab() { + //doNothing } /** @@ -224,7 +226,7 @@ public class ChartEditPane extends BasicPane implements AttributeChange, Prepare return; } - if (checkNeedsReLayout(collection.getSelectedChart())) { + if (isNeedsReLayout(collection.getSelectedChart())) { reLayout(collection.getSelectedChart()); } @@ -265,7 +267,7 @@ public class ChartEditPane extends BasicPane implements AttributeChange, Prepare } //populate的时候看看要不要重构面板 - private boolean checkNeedsReLayout(Chart chart) { + private boolean isNeedsReLayout(Chart chart) { if (chart != null) { int lastIndex = typePane.getSelectedIndex(); int currentIndex = getSelectedChartIndex(chart); @@ -317,7 +319,7 @@ public class ChartEditPane extends BasicPane implements AttributeChange, Prepare } protected void dealWithStyleChange() { - + //doNothing } /** @@ -326,7 +328,7 @@ public class ChartEditPane extends BasicPane implements AttributeChange, Prepare * @param isFromToolBar 是否来自工具栏 */ public void styleChange(boolean isFromToolBar) { - + //doNothing } /** From 3165d1fcfe0631add57eb6f56c9d770d0c97000f Mon Sep 17 00:00:00 2001 From: juhaoyu <2335173323@qq.com> Date: Wed, 13 Sep 2017 18:45:59 +0800 Subject: [PATCH 19/22] =?UTF-8?q?BI=E5=90=AF=E5=8A=A8=E7=94=A8=E4=BA=86UIb?= =?UTF-8?q?utton=EF=BC=8C=E5=AF=BC=E8=87=B4FRCoreContext=E6=8F=90=E5=89=8D?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/design/roleAuthority/ReportAndFSManagePane.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer_base/src/com/fr/design/roleAuthority/ReportAndFSManagePane.java b/designer_base/src/com/fr/design/roleAuthority/ReportAndFSManagePane.java index 4555c336b..98c570786 100644 --- a/designer_base/src/com/fr/design/roleAuthority/ReportAndFSManagePane.java +++ b/designer_base/src/com/fr/design/roleAuthority/ReportAndFSManagePane.java @@ -1 +1 @@ -package com.fr.design.roleAuthority; import com.fr.base.BaseUtils; import com.fr.base.FRCoreContext; import com.fr.design.actions.UpdateAction; import com.fr.design.constants.UIConstants; import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.tabledata.Prepare4DataSourceChange; import com.fr.design.gui.ibutton.UIHeadGroup; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.itoolbar.UIToolbar; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DockingView; import com.fr.design.menu.ToolBarDef; import com.fr.general.Inter; import com.fr.general.VT4FR; import javax.swing.*; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.event.TreeSelectionEvent; import javax.swing.tree.TreeNode; import javax.swing.tree.TreePath; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.util.Enumeration; /** * 设计器左下角面板,用于在权限编辑时存放角色 * Author : daisy * Date: 13-8-30 * Time: 下午2:22 */ public class ReportAndFSManagePane extends DockingView implements Prepare4DataSourceChange { private static final int REPORT_PLATEFORM_MANAGE = 0; private static final int FS_MANAGE = 1; private static final int LEFT_GAP = -125; private static boolean isSupportFS = false; private TreePath treePath = null; private static ReportAndFSManagePane singleton = new ReportAndFSManagePane(); private static RoleTree roleTree; // carl:我先屏了,现在半拉子,等客户要了再好好做 // private AddAction addAction = new AddAction(); // private RemoveAction removeAction = new RemoveAction(); private RefreshAction refreshAction = new RefreshAction(); private UIHeadGroup buttonGroup; private RoleSourceOP op; protected String[] roleNames = new String[2]; public synchronized static ReportAndFSManagePane getInstance() { singleton.op = new RoleSourceOP(); singleton.op.setDataMode(isSupportFS ? FS_MANAGE : REPORT_PLATEFORM_MANAGE); singleton.setDefaultSelectedRole(); return singleton; } public ReportAndFSManagePane() { initRoleTree(); this.setLayout(new BorderLayout(4, 0)); this.setBorder(null); this.add(iniToolBarPane(), BorderLayout.NORTH); refreshAction.setEnabled(true); UIScrollPane scrollPane = new UIScrollPane(roleTree); scrollPane.setBorder(BorderFactory.createEmptyBorder(0, 24, 0, 0)); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); initbuttonGroup(); JPanel jPanel = new JPanel(new BorderLayout(4, 4)); JPanel buttonPane = new JPanel(new GridLayout()); buttonPane.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, UIConstants.LINE_COLOR)); buttonPane.add(buttonGroup, BorderLayout.CENTER); jPanel.add(buttonPane, BorderLayout.NORTH); jPanel.add(scrollPane, BorderLayout.CENTER); this.add(jPanel, BorderLayout.CENTER); registerDSChangeListener(); } private void initRoleTree() { roleTree = new RoleTree() { public void refreshRoleTree(String selectedRole) { super.refreshRoleTree(selectedRole); changeAlreadyEditedPaneRole(selectedRole); } protected void doWithValueChanged(TreeSelectionEvent e) { super.doWithValueChanged(e); TreeNode root = (TreeNode) roleTree.getModel().getRoot(); TreePath parent = new TreePath(root); setSelectedRole(roleTree.getSelectedRoleName(), parent); } protected void setTabRoleName(String roleName) { roleNames[getMode()] = roleTree.getSelectedRoleName(); } }; roleTree.setEnabled(true); roleTree.setEditable(false); // RoleTreeCellEditor treeCellEditor = new RoleTreeCellEditor(new UITextField()); // treeCellEditor.addCellEditorListener(treeCellEditor); // roleTree.setCellEditor(treeCellEditor); roleTree.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { super.mouseClicked(e); roleTree.setEditable(false); // int row = roleTree.getRowForLocation(e.getX(), e.getY()); // TreePath path = roleTree.getPathForLocation(e.getX(), e.getY()); // if (e.getClickCount() == 2 && buttonGroup.getSelectedIndex() == REPORT_PLATEFORM_MANAGE) { // PrivilegeManagerProvider pm = PrivilegeManager.getProviderInstance(); // AuthenticationProvider ap = pm.getAuthenticationProvider(); // if (!(ap instanceof DaoAuthenticationProvider)) { // roleTree.setEditable(true); // roleTree.startEditingAtPath(path); // treePath = path; // } // } } }); } private void changeAlreadyEditedPaneRole(String selectedRole) { RolesAlreadyEditedPane.getInstance().refreshDockingView(); RoleTree roleTree = RolesAlreadyEditedPane.getInstance().getRoleTree(); TreeNode root = (TreeNode) roleTree.getModel().getRoot(); TreePath parent = new TreePath(root); roleTree.setSelectedRole(selectedRole, parent); } public void setDefaultSelectedRole() { //设置选中的节点 TreeNode root = (TreeNode) roleTree.getModel().getRoot(); TreePath parent = new TreePath(root); ExpandMutableTreeNode node = (ExpandMutableTreeNode) parent.getLastPathComponent(); String selectedRole = null; if (singleton != null) { selectedRole = roleNames[getMode()]; } if (selectedRole == null) { if (node.getChildCount() <= 0 || node.getFirstChild().getChildCount() <= 0) { return; } selectedRole = node.getFirstChild().getChildAt(0).toString(); } roleTree.setSelectedRole(selectedRole, parent); } public RoleTree getRoleTree() { return roleTree; } /** * 检查f) 每增删改一个角色信息(及时保存),先对比下privilege下之前的角色信息有没有发生变化(即在此期间有没有在其他途径中修改过) */ private void checkChanges() { //如若有变化,则弹出下面的对话框 int returnVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("FR-Designer_Role_changed_isRefresh") + "?", Inter.getLocText("FR-Designer_Refresh"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE); if (returnVal == JOptionPane.OK_OPTION) { roleTree.refreshTreeNode(); expandTree(roleTree, true); roleTree.updateUI(); } } private JPanel iniToolBarPane() { ToolBarDef toolbarDef = new ToolBarDef(); toolbarDef.addShortCut(refreshAction); UIToolbar toolBar = ToolBarDef.createJToolBar(); toolbarDef.updateToolBar(toolBar); JPanel toolbarPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); toolbarPane.add(toolBar, BorderLayout.CENTER); return toolbarPane; } private void initbuttonGroup() { isSupportFS = supportFineDecision(); Icon[] iconArray = null; String[] textArray = null; if (isSupportFS) { iconArray = new Icon[]{BaseUtils.readIcon("/com/fr/web/images/platform/demo.png")}; textArray = new String[]{Inter.getLocText("FR-Designer_FS_Name")}; } else { iconArray = new Icon[]{BaseUtils.readIcon("/com/fr/web/images/platform/platform_16_16.png")}; textArray = new String[]{Inter.getLocText("M_Server-Platform_Manager")}; } buttonGroup = new UIHeadGroup(iconArray, textArray) { public void tabChanged(int index) { roleTree.setEditable(false); if (op != null) { op.setDataMode(getMode()); //判断是否可编辑 refreshDockingView(); } setDefaultSelectedRole(); if (singleton != null) { changeAlreadyEditedPaneRole(roleNames[getMode()]); } } }; buttonGroup.setBorder(BorderFactory.createMatteBorder(1, LEFT_GAP, 0, 0, UIConstants.LINE_COLOR)); buttonGroup.setNeedLeftRightOutLine(false); } private boolean supportFineDecision() { byte[] bytes = FRCoreContext.getBytes(); return VT4FR.isLicAvailable(bytes) && VT4FR.FS_BI.support(); } private int getMode(){ return isSupportFS?FS_MANAGE: REPORT_PLATEFORM_MANAGE; } // /** // * 检查看看是否可以增删刷新按钮是都可以编辑,并且检查角色树是不是可以编辑 // */ // public void checkToolButtonsEnabled() { // if (buttonGroup.getSelectedIndex() == REPORT_PLATEFORM_MANAGE) { // PrivilegeManagerProvider pm = PrivilegeManager.getProviderInstance(); // AuthenticationProvider ap = pm.getAuthenticationProvider(); // PrivilegeFilter pf = pm.getPrivilegeFilter(); // boolean isClickable = !(ap instanceof DaoAuthenticationProvider) // && pf instanceof AuthorityControlFilter; // addAction.setEnabled(isClickable); // removeAction.setEnabled(isClickable); // } else { // addAction.setEnabled(false); // removeAction.setEnabled(false); // } // // } /** * 刷新界面 */ public void refreshDockingView() { populate(new RoleSourceOP()); // this.checkToolButtonsEnabled(); } private void populate(RoleSourceOP op) { this.op = op; roleTree.populate(op); expandTree(roleTree, true); } public String getViewTitle() { return null; } public Icon getViewIcon() { return null; } /** * 最佳定位 * @return 定位 */ public Location preferredLocation() { return null; } /** * 注册数据库改变的响应的Listener */ public void registerDSChangeListener() { DesignTableDataManager.addDsChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { roleTree.refreshTreeNode(); expandTree(roleTree, true); roleTree.updateUI(); } }); } // private class AddAction extends UpdateAction { // public AddAction() { // this.setName(Inter.getLocText("Add")); // this.setSmallIcon(BaseUtils.readIcon("/com/fr/base/images/cell/control/add.png")); // } // // @Override // public void actionPerformed(ActionEvent e) { // refreshDockingView(); // // DefaultTreeModel treeModel = (DefaultTreeModel) roleTree.getModel(); // ExpandMutableTreeNode root = (ExpandMutableTreeNode) treeModel.getRoot(); // ExpandMutableTreeNode parentNode = (ExpandMutableTreeNode) root.getChildAt(0); // String newName = Inter.getLocText("newNode") + (++newIndex); // parentNode.add(new ExpandMutableTreeNode(newName)); // op.addAction(newName); // roleTree.updateUI(); // // try { // synchronized (AuthorityRoleDAOManager.class) { // AuthorityControlFilter pf = AuthorityRoleDAOManager.getAuthControlFilter(true); // // if (AuthorityRoleDAOManager.getAuthorityAllocation(pf, newName) != null) { // newName = Inter.getLocText("newNode") + (++newIndex); // roleTree.refreshTreeNode(); // expandTree(roleTree, true); // } // // AuthorityRoleDAOManager.addAuthorityRole(pf, new Authority(newName), new Allocation(), false, true); // // AuthorityRoleDAOManager.doEnd(pf); // } // } catch (Exception e1) { // FRContext.getLogger().error(e1.getMessage(), e1); // } // } // } // private class RemoveAction extends UpdateAction { // // public RemoveAction() { // this.setName(Inter.getLocText("Remove")); // this.setSmallIcon(UIConstants.CLEAR_ICON); // } // // @Override // public void actionPerformed(ActionEvent e) { // // // NameObject selectedNO = roleTree.getSelectedNameObject(); // // if (selectedNO == null) { // return; // } // // int returnVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("Utils-Are_you_sure_to_remove_the_selected_item") + ":" + selectedNO.getName() + "?", // Inter.getLocText("Remove"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); // if (returnVal == JOptionPane.OK_OPTION) { // op.removeAction(selectedNO.getName()); // // try { // AuthorityControlFilter pf = AuthorityRoleDAOManager.getAuthControlFilter(true); // // AuthorityRoleDAOManager.removeAuthorityRole(pf, new Authority(selectedNO.getName()), true); // AuthorityRoleDAOManager.doEnd(pf); // } catch (Exception e1) { // FRContext.getLogger().error(e1.getMessage(), e1); // } // // roleTree.refreshTreeNode(); // expandTree(roleTree, true); // roleTree.updateUI(); // roleTree.requestFocus(); // roleTree.setSelectionRow(roleTree.getRowCount() - 1); // } // } // } /* * 刷新ReportletsTree */ private class RefreshAction extends UpdateAction { public RefreshAction() { this.setName(Inter.getLocText("FR-Designer_Refresh")); this.setSmallIcon(UIConstants.REFRESH_ICON); } @Override public void actionPerformed(ActionEvent evt) { roleTree.refreshTreeNode(); expandTree(roleTree, true); roleTree.updateUI(); } } // private class RoleTreeCellEditor extends DefaultCellEditor implements TreeCellEditor, CellEditorListener { // // private NameObject editingNO; // private String oldName; // private String newName; // private UITextField jTextField; // // public RoleTreeCellEditor(final UITextField textField) { // super(textField); // this.jTextField = textField; // this.jTextField.setPreferredSize(new Dimension(DesignerEnvManager.getEnvManager().getLastWestRegionContainerWidth() - 5, this.jTextField.getHeight())); // } // // @Override // public Component getTreeCellEditorComponent(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row) { // editingNO = ReportAndFSManagePane.this.roleTree.getSelectedNameObject(); // oldName = editingNO.getName(); // // delegate.setValue(oldName); // // editorComponent.setPreferredSize(new java.awt.Dimension(ReportAndFSManagePane.this.getPreferredSize().width, editorComponent.getPreferredSize().height)); // // return editorComponent; // } // // @Override // // public boolean isCellEditable(EventObject anEvent) { // NameObject no = ReportAndFSManagePane.this.roleTree.getSelectedNameObject(); // return !(no.getName() == Inter.getLocText("Role")); // } // // @Override // public Object getCellEditorValue() { // newName = super.getCellEditorValue().toString(); // editingNO.setName(newName); // return editingNO; // } // // // private boolean checkRoleNameNotEmpty() { // refreshDockingView(); // // String currentText = delegate.getCellEditorValue().toString(); // boolean isContained = false; // AuthorityControlFilter pf = AuthorityRoleDAOManager.getAuthControlFilter(false); // if (pf != null && // !ComparatorUtils.equals(oldName, currentText)) { // try { // Iterator iterator = AuthorityRoleDAOManager.authorityAllocationIterator(pf); // // while (iterator.hasNext()) { // AuthorityAllocation authorityAllocation = (AuthorityAllocation) ((Map.Entry) iterator.next()) // .getValue(); // Authority _authority = authorityAllocation.getAuthority(); // if(ComparatorUtils.equals(_authority.getName(), currentText)){ // isContained = true; // break; // } // } // } catch (Exception e) { // } // } // // if (currentText.isEmpty() || isContained) { // JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("RoleName_Can_Not_Be_Null") + "!"); // roleTree.refreshTreeNode(); // expandTree(roleTree, true); // delegate.setValue(oldName); // return false; // } // return true; // } // // /* // * 下面两个方法是CellEditorListener的 // */ // @Override // public void editingCanceled(ChangeEvent e) { // if (!checkRoleNameNotEmpty()) { // treePath = null; // return; // } // roleTree.stopEditing(); // if (treePath == null) { // return; // } // changeValue(); // roleTree.refreshTreeNode(); // expandTree(roleTree, true); // } // // @Override // public void editingStopped(ChangeEvent e) { // if (!checkRoleNameNotEmpty()) { // treePath = null; // return; // } // changeValue(); // roleTree.refreshTreeNode(); // expandTree(roleTree, true); // roleTree.updateUI(); // } // // private void changeValue() { // newName = delegate.getCellEditorValue().toString(); // if (!newName.isEmpty() && newName != oldName) { // roleTree.setSelectedRoleName(newName); // op.rename(oldName, newName); // // AuthorityControlFilter pf = AuthorityRoleDAOManager.getAuthControlFilter(false); // if (pf != null) { // try { // Iterator iterator = AuthorityRoleDAOManager.authorityAllocationIterator(pf); // // while (iterator.hasNext()) { // AuthorityAllocation authorityAllocation = (AuthorityAllocation) ((Map.Entry) iterator.next()) // .getValue(); // Authority _authority = authorityAllocation.getAuthority(); // if (ComparatorUtils.equals(_authority.getName(), oldName)) { // _authority.setName(newName); // } // } // } catch (Exception e) { // } // } // // try { // AuthorityRoleDAOManager.doEnd(pf); // } catch (Exception e) { // FRContext.getLogger().error(e.getMessage(), e); // } // } // } // } /** * 展开树 * @param tree 树 * @param isExpand 是否展开 */ public void expandTree(JTree tree, boolean isExpand) { TreeNode root = (TreeNode) tree.getModel().getRoot(); expandAll(tree, new TreePath(root), isExpand); } private void expandAll(JTree tree, TreePath parent, boolean expand) { TreeNode node = (TreeNode) parent.getLastPathComponent(); if (node.getChildCount() >= 0) { for (Enumeration e = node.children(); e.hasMoreElements(); ) { TreeNode n = (TreeNode) e.nextElement(); TreePath path = parent.pathByAddingChild(n); expandAll(tree, path, expand); } } if (expand) { tree.expandPath(parent); } else { tree.collapsePath(parent); } } } \ No newline at end of file +package com.fr.design.roleAuthority; import com.fr.base.BaseUtils; import com.fr.base.FRCoreContext; import com.fr.design.actions.UpdateAction; import com.fr.design.constants.UIConstants; import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.tabledata.Prepare4DataSourceChange; import com.fr.design.gui.ibutton.UIHeadGroup; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.itoolbar.UIToolbar; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DockingView; import com.fr.design.menu.ToolBarDef; import com.fr.general.Inter; import com.fr.general.VT4FR; import javax.swing.*; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.event.TreeSelectionEvent; import javax.swing.tree.TreeNode; import javax.swing.tree.TreePath; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.util.Enumeration; /** * 设计器左下角面板,用于在权限编辑时存放角色 * Author : daisy * Date: 13-8-30 * Time: 下午2:22 */ public class ReportAndFSManagePane extends DockingView implements Prepare4DataSourceChange { private static final int REPORT_PLATEFORM_MANAGE = 0; private static final int FS_MANAGE = 1; private static final int LEFT_GAP = -125; private static boolean isSupportFS = false; private TreePath treePath = null; private static ReportAndFSManagePane singleton = new ReportAndFSManagePane(); private static RoleTree roleTree; // carl:我先屏了,现在半拉子,等客户要了再好好做 // private AddAction addAction = new AddAction(); // private RemoveAction removeAction = new RemoveAction(); private RefreshAction refreshAction = new RefreshAction(); private UIHeadGroup buttonGroup; private RoleSourceOP op; protected String[] roleNames = new String[2]; public synchronized static ReportAndFSManagePane getInstance() { singleton.op = new RoleSourceOP(); singleton.op.setDataMode(isSupportFS ? FS_MANAGE : REPORT_PLATEFORM_MANAGE); singleton.setDefaultSelectedRole(); return singleton; } public ReportAndFSManagePane() { initRoleTree(); this.setLayout(new BorderLayout(4, 0)); this.setBorder(null); this.add(iniToolBarPane(), BorderLayout.NORTH); refreshAction.setEnabled(true); UIScrollPane scrollPane = new UIScrollPane(roleTree); scrollPane.setBorder(BorderFactory.createEmptyBorder(0, 24, 0, 0)); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); initbuttonGroup(); JPanel jPanel = new JPanel(new BorderLayout(4, 4)); JPanel buttonPane = new JPanel(new GridLayout()); buttonPane.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, UIConstants.LINE_COLOR)); buttonPane.add(buttonGroup, BorderLayout.CENTER); jPanel.add(buttonPane, BorderLayout.NORTH); jPanel.add(scrollPane, BorderLayout.CENTER); this.add(jPanel, BorderLayout.CENTER); registerDSChangeListener(); } private void initRoleTree() { roleTree = new RoleTree() { public void refreshRoleTree(String selectedRole) { super.refreshRoleTree(selectedRole); changeAlreadyEditedPaneRole(selectedRole); } protected void doWithValueChanged(TreeSelectionEvent e) { super.doWithValueChanged(e); TreeNode root = (TreeNode) roleTree.getModel().getRoot(); TreePath parent = new TreePath(root); setSelectedRole(roleTree.getSelectedRoleName(), parent); } protected void setTabRoleName(String roleName) { roleNames[getMode()] = roleTree.getSelectedRoleName(); } }; roleTree.setEnabled(true); roleTree.setEditable(false); // RoleTreeCellEditor treeCellEditor = new RoleTreeCellEditor(new UITextField()); // treeCellEditor.addCellEditorListener(treeCellEditor); // roleTree.setCellEditor(treeCellEditor); roleTree.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { super.mouseClicked(e); roleTree.setEditable(false); // int row = roleTree.getRowForLocation(e.getX(), e.getY()); // TreePath path = roleTree.getPathForLocation(e.getX(), e.getY()); // if (e.getClickCount() == 2 && buttonGroup.getSelectedIndex() == REPORT_PLATEFORM_MANAGE) { // PrivilegeManagerProvider pm = PrivilegeManager.getProviderInstance(); // AuthenticationProvider ap = pm.getAuthenticationProvider(); // if (!(ap instanceof DaoAuthenticationProvider)) { // roleTree.setEditable(true); // roleTree.startEditingAtPath(path); // treePath = path; // } // } } }); } private void changeAlreadyEditedPaneRole(String selectedRole) { RolesAlreadyEditedPane.getInstance().refreshDockingView(); RoleTree roleTree = RolesAlreadyEditedPane.getInstance().getRoleTree(); TreeNode root = (TreeNode) roleTree.getModel().getRoot(); TreePath parent = new TreePath(root); roleTree.setSelectedRole(selectedRole, parent); } public void setDefaultSelectedRole() { //设置选中的节点 TreeNode root = (TreeNode) roleTree.getModel().getRoot(); TreePath parent = new TreePath(root); ExpandMutableTreeNode node = (ExpandMutableTreeNode) parent.getLastPathComponent(); String selectedRole = null; if (singleton != null) { selectedRole = roleNames[getMode()]; } if (selectedRole == null) { if (node.getChildCount() <= 0 || node.getFirstChild().getChildCount() <= 0) { return; } selectedRole = node.getFirstChild().getChildAt(0).toString(); } roleTree.setSelectedRole(selectedRole, parent); } public RoleTree getRoleTree() { return roleTree; } /** * 检查f) 每增删改一个角色信息(及时保存),先对比下privilege下之前的角色信息有没有发生变化(即在此期间有没有在其他途径中修改过) */ private void checkChanges() { //如若有变化,则弹出下面的对话框 int returnVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("FR-Designer_Role_changed_isRefresh") + "?", Inter.getLocText("FR-Designer_Refresh"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE); if (returnVal == JOptionPane.OK_OPTION) { roleTree.refreshTreeNode(); expandTree(roleTree, true); roleTree.updateUI(); } } private JPanel iniToolBarPane() { ToolBarDef toolbarDef = new ToolBarDef(); toolbarDef.addShortCut(refreshAction); UIToolbar toolBar = ToolBarDef.createJToolBar(); toolbarDef.updateToolBar(toolBar); JPanel toolbarPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); toolbarPane.add(toolBar, BorderLayout.CENTER); return toolbarPane; } private void initbuttonGroup() { Icon[] iconArray = new Icon[]{BaseUtils.readIcon("/com/fr/web/images/platform/demo.png")}; String[] textArray = new String[]{Inter.getLocText("FR-Designer_FS_Name")}; buttonGroup = new UIHeadGroup(iconArray, textArray) { public void tabChanged(int index) { roleTree.setEditable(false); if (op != null) { op.setDataMode(getMode()); //判断是否可编辑 refreshDockingView(); } setDefaultSelectedRole(); if (singleton != null) { changeAlreadyEditedPaneRole(roleNames[getMode()]); } } }; buttonGroup.setBorder(BorderFactory.createMatteBorder(1, LEFT_GAP, 0, 0, UIConstants.LINE_COLOR)); buttonGroup.setNeedLeftRightOutLine(false); } private int getMode(){ return isSupportFS?FS_MANAGE: REPORT_PLATEFORM_MANAGE; } // /** // * 检查看看是否可以增删刷新按钮是都可以编辑,并且检查角色树是不是可以编辑 // */ // public void checkToolButtonsEnabled() { // if (buttonGroup.getSelectedIndex() == REPORT_PLATEFORM_MANAGE) { // PrivilegeManagerProvider pm = PrivilegeManager.getProviderInstance(); // AuthenticationProvider ap = pm.getAuthenticationProvider(); // PrivilegeFilter pf = pm.getPrivilegeFilter(); // boolean isClickable = !(ap instanceof DaoAuthenticationProvider) // && pf instanceof AuthorityControlFilter; // addAction.setEnabled(isClickable); // removeAction.setEnabled(isClickable); // } else { // addAction.setEnabled(false); // removeAction.setEnabled(false); // } // // } /** * 刷新界面 */ public void refreshDockingView() { populate(new RoleSourceOP()); // this.checkToolButtonsEnabled(); } private void populate(RoleSourceOP op) { this.op = op; roleTree.populate(op); expandTree(roleTree, true); } public String getViewTitle() { return null; } public Icon getViewIcon() { return null; } /** * 最佳定位 * @return 定位 */ public Location preferredLocation() { return null; } /** * 注册数据库改变的响应的Listener */ public void registerDSChangeListener() { DesignTableDataManager.addDsChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { roleTree.refreshTreeNode(); expandTree(roleTree, true); roleTree.updateUI(); } }); } // private class AddAction extends UpdateAction { // public AddAction() { // this.setName(Inter.getLocText("Add")); // this.setSmallIcon(BaseUtils.readIcon("/com/fr/base/images/cell/control/add.png")); // } // // @Override // public void actionPerformed(ActionEvent e) { // refreshDockingView(); // // DefaultTreeModel treeModel = (DefaultTreeModel) roleTree.getModel(); // ExpandMutableTreeNode root = (ExpandMutableTreeNode) treeModel.getRoot(); // ExpandMutableTreeNode parentNode = (ExpandMutableTreeNode) root.getChildAt(0); // String newName = Inter.getLocText("newNode") + (++newIndex); // parentNode.add(new ExpandMutableTreeNode(newName)); // op.addAction(newName); // roleTree.updateUI(); // // try { // synchronized (AuthorityRoleDAOManager.class) { // AuthorityControlFilter pf = AuthorityRoleDAOManager.getAuthControlFilter(true); // // if (AuthorityRoleDAOManager.getAuthorityAllocation(pf, newName) != null) { // newName = Inter.getLocText("newNode") + (++newIndex); // roleTree.refreshTreeNode(); // expandTree(roleTree, true); // } // // AuthorityRoleDAOManager.addAuthorityRole(pf, new Authority(newName), new Allocation(), false, true); // // AuthorityRoleDAOManager.doEnd(pf); // } // } catch (Exception e1) { // FRContext.getLogger().error(e1.getMessage(), e1); // } // } // } // private class RemoveAction extends UpdateAction { // // public RemoveAction() { // this.setName(Inter.getLocText("Remove")); // this.setSmallIcon(UIConstants.CLEAR_ICON); // } // // @Override // public void actionPerformed(ActionEvent e) { // // // NameObject selectedNO = roleTree.getSelectedNameObject(); // // if (selectedNO == null) { // return; // } // // int returnVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("Utils-Are_you_sure_to_remove_the_selected_item") + ":" + selectedNO.getName() + "?", // Inter.getLocText("Remove"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); // if (returnVal == JOptionPane.OK_OPTION) { // op.removeAction(selectedNO.getName()); // // try { // AuthorityControlFilter pf = AuthorityRoleDAOManager.getAuthControlFilter(true); // // AuthorityRoleDAOManager.removeAuthorityRole(pf, new Authority(selectedNO.getName()), true); // AuthorityRoleDAOManager.doEnd(pf); // } catch (Exception e1) { // FRContext.getLogger().error(e1.getMessage(), e1); // } // // roleTree.refreshTreeNode(); // expandTree(roleTree, true); // roleTree.updateUI(); // roleTree.requestFocus(); // roleTree.setSelectionRow(roleTree.getRowCount() - 1); // } // } // } /* * 刷新ReportletsTree */ private class RefreshAction extends UpdateAction { public RefreshAction() { this.setName(Inter.getLocText("FR-Designer_Refresh")); this.setSmallIcon(UIConstants.REFRESH_ICON); } @Override public void actionPerformed(ActionEvent evt) { roleTree.refreshTreeNode(); expandTree(roleTree, true); roleTree.updateUI(); } } // private class RoleTreeCellEditor extends DefaultCellEditor implements TreeCellEditor, CellEditorListener { // // private NameObject editingNO; // private String oldName; // private String newName; // private UITextField jTextField; // // public RoleTreeCellEditor(final UITextField textField) { // super(textField); // this.jTextField = textField; // this.jTextField.setPreferredSize(new Dimension(DesignerEnvManager.getEnvManager().getLastWestRegionContainerWidth() - 5, this.jTextField.getHeight())); // } // // @Override // public Component getTreeCellEditorComponent(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row) { // editingNO = ReportAndFSManagePane.this.roleTree.getSelectedNameObject(); // oldName = editingNO.getName(); // // delegate.setValue(oldName); // // editorComponent.setPreferredSize(new java.awt.Dimension(ReportAndFSManagePane.this.getPreferredSize().width, editorComponent.getPreferredSize().height)); // // return editorComponent; // } // // @Override // // public boolean isCellEditable(EventObject anEvent) { // NameObject no = ReportAndFSManagePane.this.roleTree.getSelectedNameObject(); // return !(no.getName() == Inter.getLocText("Role")); // } // // @Override // public Object getCellEditorValue() { // newName = super.getCellEditorValue().toString(); // editingNO.setName(newName); // return editingNO; // } // // // private boolean checkRoleNameNotEmpty() { // refreshDockingView(); // // String currentText = delegate.getCellEditorValue().toString(); // boolean isContained = false; // AuthorityControlFilter pf = AuthorityRoleDAOManager.getAuthControlFilter(false); // if (pf != null && // !ComparatorUtils.equals(oldName, currentText)) { // try { // Iterator iterator = AuthorityRoleDAOManager.authorityAllocationIterator(pf); // // while (iterator.hasNext()) { // AuthorityAllocation authorityAllocation = (AuthorityAllocation) ((Map.Entry) iterator.next()) // .getValue(); // Authority _authority = authorityAllocation.getAuthority(); // if(ComparatorUtils.equals(_authority.getName(), currentText)){ // isContained = true; // break; // } // } // } catch (Exception e) { // } // } // // if (currentText.isEmpty() || isContained) { // JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("RoleName_Can_Not_Be_Null") + "!"); // roleTree.refreshTreeNode(); // expandTree(roleTree, true); // delegate.setValue(oldName); // return false; // } // return true; // } // // /* // * 下面两个方法是CellEditorListener的 // */ // @Override // public void editingCanceled(ChangeEvent e) { // if (!checkRoleNameNotEmpty()) { // treePath = null; // return; // } // roleTree.stopEditing(); // if (treePath == null) { // return; // } // changeValue(); // roleTree.refreshTreeNode(); // expandTree(roleTree, true); // } // // @Override // public void editingStopped(ChangeEvent e) { // if (!checkRoleNameNotEmpty()) { // treePath = null; // return; // } // changeValue(); // roleTree.refreshTreeNode(); // expandTree(roleTree, true); // roleTree.updateUI(); // } // // private void changeValue() { // newName = delegate.getCellEditorValue().toString(); // if (!newName.isEmpty() && newName != oldName) { // roleTree.setSelectedRoleName(newName); // op.rename(oldName, newName); // // AuthorityControlFilter pf = AuthorityRoleDAOManager.getAuthControlFilter(false); // if (pf != null) { // try { // Iterator iterator = AuthorityRoleDAOManager.authorityAllocationIterator(pf); // // while (iterator.hasNext()) { // AuthorityAllocation authorityAllocation = (AuthorityAllocation) ((Map.Entry) iterator.next()) // .getValue(); // Authority _authority = authorityAllocation.getAuthority(); // if (ComparatorUtils.equals(_authority.getName(), oldName)) { // _authority.setName(newName); // } // } // } catch (Exception e) { // } // } // // try { // AuthorityRoleDAOManager.doEnd(pf); // } catch (Exception e) { // FRContext.getLogger().error(e.getMessage(), e); // } // } // } // } /** * 展开树 * @param tree 树 * @param isExpand 是否展开 */ public void expandTree(JTree tree, boolean isExpand) { TreeNode root = (TreeNode) tree.getModel().getRoot(); expandAll(tree, new TreePath(root), isExpand); } private void expandAll(JTree tree, TreePath parent, boolean expand) { TreeNode node = (TreeNode) parent.getLastPathComponent(); if (node.getChildCount() >= 0) { for (Enumeration e = node.children(); e.hasMoreElements(); ) { TreeNode n = (TreeNode) e.nextElement(); TreePath path = parent.pathByAddingChild(n); expandAll(tree, path, expand); } } if (expand) { tree.expandPath(parent); } else { tree.collapsePath(parent); } } } \ No newline at end of file From d472801c8c015b158d18a34320d97a967c4cc6c0 Mon Sep 17 00:00:00 2001 From: juhaoyu <2335173323@qq.com> Date: Wed, 13 Sep 2017 18:47:01 +0800 Subject: [PATCH 20/22] =?UTF-8?q?BI=E5=90=AF=E5=8A=A8=E7=94=A8=E4=BA=86UIB?= =?UTF-8?q?utton=EF=BC=8C=E5=AF=BC=E8=87=B4FRCoreContext=E6=8F=90=E5=89=8D?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/design/roleAuthority/ReportAndFSManagePane.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer_base/src/com/fr/design/roleAuthority/ReportAndFSManagePane.java b/designer_base/src/com/fr/design/roleAuthority/ReportAndFSManagePane.java index 4555c336b..9f351fb57 100644 --- a/designer_base/src/com/fr/design/roleAuthority/ReportAndFSManagePane.java +++ b/designer_base/src/com/fr/design/roleAuthority/ReportAndFSManagePane.java @@ -1 +1 @@ -package com.fr.design.roleAuthority; import com.fr.base.BaseUtils; import com.fr.base.FRCoreContext; import com.fr.design.actions.UpdateAction; import com.fr.design.constants.UIConstants; import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.tabledata.Prepare4DataSourceChange; import com.fr.design.gui.ibutton.UIHeadGroup; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.itoolbar.UIToolbar; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DockingView; import com.fr.design.menu.ToolBarDef; import com.fr.general.Inter; import com.fr.general.VT4FR; import javax.swing.*; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.event.TreeSelectionEvent; import javax.swing.tree.TreeNode; import javax.swing.tree.TreePath; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.util.Enumeration; /** * 设计器左下角面板,用于在权限编辑时存放角色 * Author : daisy * Date: 13-8-30 * Time: 下午2:22 */ public class ReportAndFSManagePane extends DockingView implements Prepare4DataSourceChange { private static final int REPORT_PLATEFORM_MANAGE = 0; private static final int FS_MANAGE = 1; private static final int LEFT_GAP = -125; private static boolean isSupportFS = false; private TreePath treePath = null; private static ReportAndFSManagePane singleton = new ReportAndFSManagePane(); private static RoleTree roleTree; // carl:我先屏了,现在半拉子,等客户要了再好好做 // private AddAction addAction = new AddAction(); // private RemoveAction removeAction = new RemoveAction(); private RefreshAction refreshAction = new RefreshAction(); private UIHeadGroup buttonGroup; private RoleSourceOP op; protected String[] roleNames = new String[2]; public synchronized static ReportAndFSManagePane getInstance() { singleton.op = new RoleSourceOP(); singleton.op.setDataMode(isSupportFS ? FS_MANAGE : REPORT_PLATEFORM_MANAGE); singleton.setDefaultSelectedRole(); return singleton; } public ReportAndFSManagePane() { initRoleTree(); this.setLayout(new BorderLayout(4, 0)); this.setBorder(null); this.add(iniToolBarPane(), BorderLayout.NORTH); refreshAction.setEnabled(true); UIScrollPane scrollPane = new UIScrollPane(roleTree); scrollPane.setBorder(BorderFactory.createEmptyBorder(0, 24, 0, 0)); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); initbuttonGroup(); JPanel jPanel = new JPanel(new BorderLayout(4, 4)); JPanel buttonPane = new JPanel(new GridLayout()); buttonPane.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, UIConstants.LINE_COLOR)); buttonPane.add(buttonGroup, BorderLayout.CENTER); jPanel.add(buttonPane, BorderLayout.NORTH); jPanel.add(scrollPane, BorderLayout.CENTER); this.add(jPanel, BorderLayout.CENTER); registerDSChangeListener(); } private void initRoleTree() { roleTree = new RoleTree() { public void refreshRoleTree(String selectedRole) { super.refreshRoleTree(selectedRole); changeAlreadyEditedPaneRole(selectedRole); } protected void doWithValueChanged(TreeSelectionEvent e) { super.doWithValueChanged(e); TreeNode root = (TreeNode) roleTree.getModel().getRoot(); TreePath parent = new TreePath(root); setSelectedRole(roleTree.getSelectedRoleName(), parent); } protected void setTabRoleName(String roleName) { roleNames[getMode()] = roleTree.getSelectedRoleName(); } }; roleTree.setEnabled(true); roleTree.setEditable(false); // RoleTreeCellEditor treeCellEditor = new RoleTreeCellEditor(new UITextField()); // treeCellEditor.addCellEditorListener(treeCellEditor); // roleTree.setCellEditor(treeCellEditor); roleTree.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { super.mouseClicked(e); roleTree.setEditable(false); // int row = roleTree.getRowForLocation(e.getX(), e.getY()); // TreePath path = roleTree.getPathForLocation(e.getX(), e.getY()); // if (e.getClickCount() == 2 && buttonGroup.getSelectedIndex() == REPORT_PLATEFORM_MANAGE) { // PrivilegeManagerProvider pm = PrivilegeManager.getProviderInstance(); // AuthenticationProvider ap = pm.getAuthenticationProvider(); // if (!(ap instanceof DaoAuthenticationProvider)) { // roleTree.setEditable(true); // roleTree.startEditingAtPath(path); // treePath = path; // } // } } }); } private void changeAlreadyEditedPaneRole(String selectedRole) { RolesAlreadyEditedPane.getInstance().refreshDockingView(); RoleTree roleTree = RolesAlreadyEditedPane.getInstance().getRoleTree(); TreeNode root = (TreeNode) roleTree.getModel().getRoot(); TreePath parent = new TreePath(root); roleTree.setSelectedRole(selectedRole, parent); } public void setDefaultSelectedRole() { //设置选中的节点 TreeNode root = (TreeNode) roleTree.getModel().getRoot(); TreePath parent = new TreePath(root); ExpandMutableTreeNode node = (ExpandMutableTreeNode) parent.getLastPathComponent(); String selectedRole = null; if (singleton != null) { selectedRole = roleNames[getMode()]; } if (selectedRole == null) { if (node.getChildCount() <= 0 || node.getFirstChild().getChildCount() <= 0) { return; } selectedRole = node.getFirstChild().getChildAt(0).toString(); } roleTree.setSelectedRole(selectedRole, parent); } public RoleTree getRoleTree() { return roleTree; } /** * 检查f) 每增删改一个角色信息(及时保存),先对比下privilege下之前的角色信息有没有发生变化(即在此期间有没有在其他途径中修改过) */ private void checkChanges() { //如若有变化,则弹出下面的对话框 int returnVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("FR-Designer_Role_changed_isRefresh") + "?", Inter.getLocText("FR-Designer_Refresh"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE); if (returnVal == JOptionPane.OK_OPTION) { roleTree.refreshTreeNode(); expandTree(roleTree, true); roleTree.updateUI(); } } private JPanel iniToolBarPane() { ToolBarDef toolbarDef = new ToolBarDef(); toolbarDef.addShortCut(refreshAction); UIToolbar toolBar = ToolBarDef.createJToolBar(); toolbarDef.updateToolBar(toolBar); JPanel toolbarPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); toolbarPane.add(toolBar, BorderLayout.CENTER); return toolbarPane; } private void initbuttonGroup() { isSupportFS = supportFineDecision(); Icon[] iconArray = null; String[] textArray = null; if (isSupportFS) { iconArray = new Icon[]{BaseUtils.readIcon("/com/fr/web/images/platform/demo.png")}; textArray = new String[]{Inter.getLocText("FR-Designer_FS_Name")}; } else { iconArray = new Icon[]{BaseUtils.readIcon("/com/fr/web/images/platform/platform_16_16.png")}; textArray = new String[]{Inter.getLocText("M_Server-Platform_Manager")}; } buttonGroup = new UIHeadGroup(iconArray, textArray) { public void tabChanged(int index) { roleTree.setEditable(false); if (op != null) { op.setDataMode(getMode()); //判断是否可编辑 refreshDockingView(); } setDefaultSelectedRole(); if (singleton != null) { changeAlreadyEditedPaneRole(roleNames[getMode()]); } } }; buttonGroup.setBorder(BorderFactory.createMatteBorder(1, LEFT_GAP, 0, 0, UIConstants.LINE_COLOR)); buttonGroup.setNeedLeftRightOutLine(false); } private boolean supportFineDecision() { byte[] bytes = FRCoreContext.getBytes(); return VT4FR.isLicAvailable(bytes) && VT4FR.FS_BI.support(); } private int getMode(){ return isSupportFS?FS_MANAGE: REPORT_PLATEFORM_MANAGE; } // /** // * 检查看看是否可以增删刷新按钮是都可以编辑,并且检查角色树是不是可以编辑 // */ // public void checkToolButtonsEnabled() { // if (buttonGroup.getSelectedIndex() == REPORT_PLATEFORM_MANAGE) { // PrivilegeManagerProvider pm = PrivilegeManager.getProviderInstance(); // AuthenticationProvider ap = pm.getAuthenticationProvider(); // PrivilegeFilter pf = pm.getPrivilegeFilter(); // boolean isClickable = !(ap instanceof DaoAuthenticationProvider) // && pf instanceof AuthorityControlFilter; // addAction.setEnabled(isClickable); // removeAction.setEnabled(isClickable); // } else { // addAction.setEnabled(false); // removeAction.setEnabled(false); // } // // } /** * 刷新界面 */ public void refreshDockingView() { populate(new RoleSourceOP()); // this.checkToolButtonsEnabled(); } private void populate(RoleSourceOP op) { this.op = op; roleTree.populate(op); expandTree(roleTree, true); } public String getViewTitle() { return null; } public Icon getViewIcon() { return null; } /** * 最佳定位 * @return 定位 */ public Location preferredLocation() { return null; } /** * 注册数据库改变的响应的Listener */ public void registerDSChangeListener() { DesignTableDataManager.addDsChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { roleTree.refreshTreeNode(); expandTree(roleTree, true); roleTree.updateUI(); } }); } // private class AddAction extends UpdateAction { // public AddAction() { // this.setName(Inter.getLocText("Add")); // this.setSmallIcon(BaseUtils.readIcon("/com/fr/base/images/cell/control/add.png")); // } // // @Override // public void actionPerformed(ActionEvent e) { // refreshDockingView(); // // DefaultTreeModel treeModel = (DefaultTreeModel) roleTree.getModel(); // ExpandMutableTreeNode root = (ExpandMutableTreeNode) treeModel.getRoot(); // ExpandMutableTreeNode parentNode = (ExpandMutableTreeNode) root.getChildAt(0); // String newName = Inter.getLocText("newNode") + (++newIndex); // parentNode.add(new ExpandMutableTreeNode(newName)); // op.addAction(newName); // roleTree.updateUI(); // // try { // synchronized (AuthorityRoleDAOManager.class) { // AuthorityControlFilter pf = AuthorityRoleDAOManager.getAuthControlFilter(true); // // if (AuthorityRoleDAOManager.getAuthorityAllocation(pf, newName) != null) { // newName = Inter.getLocText("newNode") + (++newIndex); // roleTree.refreshTreeNode(); // expandTree(roleTree, true); // } // // AuthorityRoleDAOManager.addAuthorityRole(pf, new Authority(newName), new Allocation(), false, true); // // AuthorityRoleDAOManager.doEnd(pf); // } // } catch (Exception e1) { // FRContext.getLogger().error(e1.getMessage(), e1); // } // } // } // private class RemoveAction extends UpdateAction { // // public RemoveAction() { // this.setName(Inter.getLocText("Remove")); // this.setSmallIcon(UIConstants.CLEAR_ICON); // } // // @Override // public void actionPerformed(ActionEvent e) { // // // NameObject selectedNO = roleTree.getSelectedNameObject(); // // if (selectedNO == null) { // return; // } // // int returnVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("Utils-Are_you_sure_to_remove_the_selected_item") + ":" + selectedNO.getName() + "?", // Inter.getLocText("Remove"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); // if (returnVal == JOptionPane.OK_OPTION) { // op.removeAction(selectedNO.getName()); // // try { // AuthorityControlFilter pf = AuthorityRoleDAOManager.getAuthControlFilter(true); // // AuthorityRoleDAOManager.removeAuthorityRole(pf, new Authority(selectedNO.getName()), true); // AuthorityRoleDAOManager.doEnd(pf); // } catch (Exception e1) { // FRContext.getLogger().error(e1.getMessage(), e1); // } // // roleTree.refreshTreeNode(); // expandTree(roleTree, true); // roleTree.updateUI(); // roleTree.requestFocus(); // roleTree.setSelectionRow(roleTree.getRowCount() - 1); // } // } // } /* * 刷新ReportletsTree */ private class RefreshAction extends UpdateAction { public RefreshAction() { this.setName(Inter.getLocText("FR-Designer_Refresh")); this.setSmallIcon(UIConstants.REFRESH_ICON); } @Override public void actionPerformed(ActionEvent evt) { roleTree.refreshTreeNode(); expandTree(roleTree, true); roleTree.updateUI(); } } // private class RoleTreeCellEditor extends DefaultCellEditor implements TreeCellEditor, CellEditorListener { // // private NameObject editingNO; // private String oldName; // private String newName; // private UITextField jTextField; // // public RoleTreeCellEditor(final UITextField textField) { // super(textField); // this.jTextField = textField; // this.jTextField.setPreferredSize(new Dimension(DesignerEnvManager.getEnvManager().getLastWestRegionContainerWidth() - 5, this.jTextField.getHeight())); // } // // @Override // public Component getTreeCellEditorComponent(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row) { // editingNO = ReportAndFSManagePane.this.roleTree.getSelectedNameObject(); // oldName = editingNO.getName(); // // delegate.setValue(oldName); // // editorComponent.setPreferredSize(new java.awt.Dimension(ReportAndFSManagePane.this.getPreferredSize().width, editorComponent.getPreferredSize().height)); // // return editorComponent; // } // // @Override // // public boolean isCellEditable(EventObject anEvent) { // NameObject no = ReportAndFSManagePane.this.roleTree.getSelectedNameObject(); // return !(no.getName() == Inter.getLocText("Role")); // } // // @Override // public Object getCellEditorValue() { // newName = super.getCellEditorValue().toString(); // editingNO.setName(newName); // return editingNO; // } // // // private boolean checkRoleNameNotEmpty() { // refreshDockingView(); // // String currentText = delegate.getCellEditorValue().toString(); // boolean isContained = false; // AuthorityControlFilter pf = AuthorityRoleDAOManager.getAuthControlFilter(false); // if (pf != null && // !ComparatorUtils.equals(oldName, currentText)) { // try { // Iterator iterator = AuthorityRoleDAOManager.authorityAllocationIterator(pf); // // while (iterator.hasNext()) { // AuthorityAllocation authorityAllocation = (AuthorityAllocation) ((Map.Entry) iterator.next()) // .getValue(); // Authority _authority = authorityAllocation.getAuthority(); // if(ComparatorUtils.equals(_authority.getName(), currentText)){ // isContained = true; // break; // } // } // } catch (Exception e) { // } // } // // if (currentText.isEmpty() || isContained) { // JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("RoleName_Can_Not_Be_Null") + "!"); // roleTree.refreshTreeNode(); // expandTree(roleTree, true); // delegate.setValue(oldName); // return false; // } // return true; // } // // /* // * 下面两个方法是CellEditorListener的 // */ // @Override // public void editingCanceled(ChangeEvent e) { // if (!checkRoleNameNotEmpty()) { // treePath = null; // return; // } // roleTree.stopEditing(); // if (treePath == null) { // return; // } // changeValue(); // roleTree.refreshTreeNode(); // expandTree(roleTree, true); // } // // @Override // public void editingStopped(ChangeEvent e) { // if (!checkRoleNameNotEmpty()) { // treePath = null; // return; // } // changeValue(); // roleTree.refreshTreeNode(); // expandTree(roleTree, true); // roleTree.updateUI(); // } // // private void changeValue() { // newName = delegate.getCellEditorValue().toString(); // if (!newName.isEmpty() && newName != oldName) { // roleTree.setSelectedRoleName(newName); // op.rename(oldName, newName); // // AuthorityControlFilter pf = AuthorityRoleDAOManager.getAuthControlFilter(false); // if (pf != null) { // try { // Iterator iterator = AuthorityRoleDAOManager.authorityAllocationIterator(pf); // // while (iterator.hasNext()) { // AuthorityAllocation authorityAllocation = (AuthorityAllocation) ((Map.Entry) iterator.next()) // .getValue(); // Authority _authority = authorityAllocation.getAuthority(); // if (ComparatorUtils.equals(_authority.getName(), oldName)) { // _authority.setName(newName); // } // } // } catch (Exception e) { // } // } // // try { // AuthorityRoleDAOManager.doEnd(pf); // } catch (Exception e) { // FRContext.getLogger().error(e.getMessage(), e); // } // } // } // } /** * 展开树 * @param tree 树 * @param isExpand 是否展开 */ public void expandTree(JTree tree, boolean isExpand) { TreeNode root = (TreeNode) tree.getModel().getRoot(); expandAll(tree, new TreePath(root), isExpand); } private void expandAll(JTree tree, TreePath parent, boolean expand) { TreeNode node = (TreeNode) parent.getLastPathComponent(); if (node.getChildCount() >= 0) { for (Enumeration e = node.children(); e.hasMoreElements(); ) { TreeNode n = (TreeNode) e.nextElement(); TreePath path = parent.pathByAddingChild(n); expandAll(tree, path, expand); } } if (expand) { tree.expandPath(parent); } else { tree.collapsePath(parent); } } } \ No newline at end of file +package com.fr.design.roleAuthority; import com.fr.base.BaseUtils; import com.fr.base.FRCoreContext; import com.fr.design.actions.UpdateAction; import com.fr.design.constants.UIConstants; import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.tabledata.Prepare4DataSourceChange; import com.fr.design.gui.ibutton.UIHeadGroup; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.itoolbar.UIToolbar; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DockingView; import com.fr.design.menu.ToolBarDef; import com.fr.general.Inter; import com.fr.general.VT4FR; import javax.swing.*; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.event.TreeSelectionEvent; import javax.swing.tree.TreeNode; import javax.swing.tree.TreePath; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.util.Enumeration; /** * 设计器左下角面板,用于在权限编辑时存放角色 * Author : daisy * Date: 13-8-30 * Time: 下午2:22 */ public class ReportAndFSManagePane extends DockingView implements Prepare4DataSourceChange { private static final int REPORT_PLATEFORM_MANAGE = 0; private static final int FS_MANAGE = 1; private static final int LEFT_GAP = -125; private static boolean isSupportFS = false; private TreePath treePath = null; private static ReportAndFSManagePane singleton = new ReportAndFSManagePane(); private static RoleTree roleTree; // carl:我先屏了,现在半拉子,等客户要了再好好做 // private AddAction addAction = new AddAction(); // private RemoveAction removeAction = new RemoveAction(); private RefreshAction refreshAction = new RefreshAction(); private UIHeadGroup buttonGroup; private RoleSourceOP op; protected String[] roleNames = new String[2]; public synchronized static ReportAndFSManagePane getInstance() { singleton.op = new RoleSourceOP(); singleton.op.setDataMode(isSupportFS ? FS_MANAGE : REPORT_PLATEFORM_MANAGE); singleton.setDefaultSelectedRole(); return singleton; } public ReportAndFSManagePane() { initRoleTree(); this.setLayout(new BorderLayout(4, 0)); this.setBorder(null); this.add(iniToolBarPane(), BorderLayout.NORTH); refreshAction.setEnabled(true); UIScrollPane scrollPane = new UIScrollPane(roleTree); scrollPane.setBorder(BorderFactory.createEmptyBorder(0, 24, 0, 0)); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); initbuttonGroup(); JPanel jPanel = new JPanel(new BorderLayout(4, 4)); JPanel buttonPane = new JPanel(new GridLayout()); buttonPane.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, UIConstants.LINE_COLOR)); buttonPane.add(buttonGroup, BorderLayout.CENTER); jPanel.add(buttonPane, BorderLayout.NORTH); jPanel.add(scrollPane, BorderLayout.CENTER); this.add(jPanel, BorderLayout.CENTER); registerDSChangeListener(); } private void initRoleTree() { roleTree = new RoleTree() { public void refreshRoleTree(String selectedRole) { super.refreshRoleTree(selectedRole); changeAlreadyEditedPaneRole(selectedRole); } protected void doWithValueChanged(TreeSelectionEvent e) { super.doWithValueChanged(e); TreeNode root = (TreeNode) roleTree.getModel().getRoot(); TreePath parent = new TreePath(root); setSelectedRole(roleTree.getSelectedRoleName(), parent); } protected void setTabRoleName(String roleName) { roleNames[getMode()] = roleTree.getSelectedRoleName(); } }; roleTree.setEnabled(true); roleTree.setEditable(false); // RoleTreeCellEditor treeCellEditor = new RoleTreeCellEditor(new UITextField()); // treeCellEditor.addCellEditorListener(treeCellEditor); // roleTree.setCellEditor(treeCellEditor); roleTree.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { super.mouseClicked(e); roleTree.setEditable(false); // int row = roleTree.getRowForLocation(e.getX(), e.getY()); // TreePath path = roleTree.getPathForLocation(e.getX(), e.getY()); // if (e.getClickCount() == 2 && buttonGroup.getSelectedIndex() == REPORT_PLATEFORM_MANAGE) { // PrivilegeManagerProvider pm = PrivilegeManager.getProviderInstance(); // AuthenticationProvider ap = pm.getAuthenticationProvider(); // if (!(ap instanceof DaoAuthenticationProvider)) { // roleTree.setEditable(true); // roleTree.startEditingAtPath(path); // treePath = path; // } // } } }); } private void changeAlreadyEditedPaneRole(String selectedRole) { RolesAlreadyEditedPane.getInstance().refreshDockingView(); RoleTree roleTree = RolesAlreadyEditedPane.getInstance().getRoleTree(); TreeNode root = (TreeNode) roleTree.getModel().getRoot(); TreePath parent = new TreePath(root); roleTree.setSelectedRole(selectedRole, parent); } public void setDefaultSelectedRole() { //设置选中的节点 TreeNode root = (TreeNode) roleTree.getModel().getRoot(); TreePath parent = new TreePath(root); ExpandMutableTreeNode node = (ExpandMutableTreeNode) parent.getLastPathComponent(); String selectedRole = null; if (singleton != null) { selectedRole = roleNames[getMode()]; } if (selectedRole == null) { if (node.getChildCount() <= 0 || node.getFirstChild().getChildCount() <= 0) { return; } selectedRole = node.getFirstChild().getChildAt(0).toString(); } roleTree.setSelectedRole(selectedRole, parent); } public RoleTree getRoleTree() { return roleTree; } /** * 检查f) 每增删改一个角色信息(及时保存),先对比下privilege下之前的角色信息有没有发生变化(即在此期间有没有在其他途径中修改过) */ private void checkChanges() { //如若有变化,则弹出下面的对话框 int returnVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("FR-Designer_Role_changed_isRefresh") + "?", Inter.getLocText("FR-Designer_Refresh"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE); if (returnVal == JOptionPane.OK_OPTION) { roleTree.refreshTreeNode(); expandTree(roleTree, true); roleTree.updateUI(); } } private JPanel iniToolBarPane() { ToolBarDef toolbarDef = new ToolBarDef(); toolbarDef.addShortCut(refreshAction); UIToolbar toolBar = ToolBarDef.createJToolBar(); toolbarDef.updateToolBar(toolBar); JPanel toolbarPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); toolbarPane.add(toolBar, BorderLayout.CENTER); return toolbarPane; } private void initbuttonGroup() { Icon[] iconArray = new Icon[]{BaseUtils.readIcon("/com/fr/web/images/platform/demo.png")}; String[] textArray = new String[]{Inter.getLocText("FR-Designer_FS_Name")}; buttonGroup = new UIHeadGroup(iconArray, textArray) { public void tabChanged(int index) { roleTree.setEditable(false); if (op != null) { op.setDataMode(getMode()); //判断是否可编辑 refreshDockingView(); } setDefaultSelectedRole(); if (singleton != null) { changeAlreadyEditedPaneRole(roleNames[getMode()]); } } }; buttonGroup.setBorder(BorderFactory.createMatteBorder(1, LEFT_GAP, 0, 0, UIConstants.LINE_COLOR)); buttonGroup.setNeedLeftRightOutLine(false); } private int getMode(){ return isSupportFS?FS_MANAGE: REPORT_PLATEFORM_MANAGE; } // /** // * 检查看看是否可以增删刷新按钮是都可以编辑,并且检查角色树是不是可以编辑 // */ // public void checkToolButtonsEnabled() { // if (buttonGroup.getSelectedIndex() == REPORT_PLATEFORM_MANAGE) { // PrivilegeManagerProvider pm = PrivilegeManager.getProviderInstance(); // AuthenticationProvider ap = pm.getAuthenticationProvider(); // PrivilegeFilter pf = pm.getPrivilegeFilter(); // boolean isClickable = !(ap instanceof DaoAuthenticationProvider) // && pf instanceof AuthorityControlFilter; // addAction.setEnabled(isClickable); // removeAction.setEnabled(isClickable); // } else { // addAction.setEnabled(false); // removeAction.setEnabled(false); // } // // } /** * 刷新界面 */ public void refreshDockingView() { populate(new RoleSourceOP()); // this.checkToolButtonsEnabled(); } private void populate(RoleSourceOP op) { this.op = op; roleTree.populate(op); expandTree(roleTree, true); } public String getViewTitle() { return null; } public Icon getViewIcon() { return null; } /** * 最佳定位 * @return 定位 */ public Location preferredLocation() { return null; } /** * 注册数据库改变的响应的Listener */ public void registerDSChangeListener() { DesignTableDataManager.addDsChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { roleTree.refreshTreeNode(); expandTree(roleTree, true); roleTree.updateUI(); } }); } // private class AddAction extends UpdateAction { // public AddAction() { // this.setName(Inter.getLocText("Add")); // this.setSmallIcon(BaseUtils.readIcon("/com/fr/base/images/cell/control/add.png")); // } // // @Override // public void actionPerformed(ActionEvent e) { // refreshDockingView(); // // DefaultTreeModel treeModel = (DefaultTreeModel) roleTree.getModel(); // ExpandMutableTreeNode root = (ExpandMutableTreeNode) treeModel.getRoot(); // ExpandMutableTreeNode parentNode = (ExpandMutableTreeNode) root.getChildAt(0); // String newName = Inter.getLocText("newNode") + (++newIndex); // parentNode.add(new ExpandMutableTreeNode(newName)); // op.addAction(newName); // roleTree.updateUI(); // // try { // synchronized (AuthorityRoleDAOManager.class) { // AuthorityControlFilter pf = AuthorityRoleDAOManager.getAuthControlFilter(true); // // if (AuthorityRoleDAOManager.getAuthorityAllocation(pf, newName) != null) { // newName = Inter.getLocText("newNode") + (++newIndex); // roleTree.refreshTreeNode(); // expandTree(roleTree, true); // } // // AuthorityRoleDAOManager.addAuthorityRole(pf, new Authority(newName), new Allocation(), false, true); // // AuthorityRoleDAOManager.doEnd(pf); // } // } catch (Exception e1) { // FRContext.getLogger().error(e1.getMessage(), e1); // } // } // } // private class RemoveAction extends UpdateAction { // // public RemoveAction() { // this.setName(Inter.getLocText("Remove")); // this.setSmallIcon(UIConstants.CLEAR_ICON); // } // // @Override // public void actionPerformed(ActionEvent e) { // // // NameObject selectedNO = roleTree.getSelectedNameObject(); // // if (selectedNO == null) { // return; // } // // int returnVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("Utils-Are_you_sure_to_remove_the_selected_item") + ":" + selectedNO.getName() + "?", // Inter.getLocText("Remove"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); // if (returnVal == JOptionPane.OK_OPTION) { // op.removeAction(selectedNO.getName()); // // try { // AuthorityControlFilter pf = AuthorityRoleDAOManager.getAuthControlFilter(true); // // AuthorityRoleDAOManager.removeAuthorityRole(pf, new Authority(selectedNO.getName()), true); // AuthorityRoleDAOManager.doEnd(pf); // } catch (Exception e1) { // FRContext.getLogger().error(e1.getMessage(), e1); // } // // roleTree.refreshTreeNode(); // expandTree(roleTree, true); // roleTree.updateUI(); // roleTree.requestFocus(); // roleTree.setSelectionRow(roleTree.getRowCount() - 1); // } // } // } /* * 刷新ReportletsTree */ private class RefreshAction extends UpdateAction { public RefreshAction() { this.setName(Inter.getLocText("FR-Designer_Refresh")); this.setSmallIcon(UIConstants.REFRESH_ICON); } @Override public void actionPerformed(ActionEvent evt) { roleTree.refreshTreeNode(); expandTree(roleTree, true); roleTree.updateUI(); } } // private class RoleTreeCellEditor extends DefaultCellEditor implements TreeCellEditor, CellEditorListener { // // private NameObject editingNO; // private String oldName; // private String newName; // private UITextField jTextField; // // public RoleTreeCellEditor(final UITextField textField) { // super(textField); // this.jTextField = textField; // this.jTextField.setPreferredSize(new Dimension(DesignerEnvManager.getEnvManager().getLastWestRegionContainerWidth() - 5, this.jTextField.getHeight())); // } // // @Override // public Component getTreeCellEditorComponent(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row) { // editingNO = ReportAndFSManagePane.this.roleTree.getSelectedNameObject(); // oldName = editingNO.getName(); // // delegate.setValue(oldName); // // editorComponent.setPreferredSize(new java.awt.Dimension(ReportAndFSManagePane.this.getPreferredSize().width, editorComponent.getPreferredSize().height)); // // return editorComponent; // } // // @Override // // public boolean isCellEditable(EventObject anEvent) { // NameObject no = ReportAndFSManagePane.this.roleTree.getSelectedNameObject(); // return !(no.getName() == Inter.getLocText("Role")); // } // // @Override // public Object getCellEditorValue() { // newName = super.getCellEditorValue().toString(); // editingNO.setName(newName); // return editingNO; // } // // // private boolean checkRoleNameNotEmpty() { // refreshDockingView(); // // String currentText = delegate.getCellEditorValue().toString(); // boolean isContained = false; // AuthorityControlFilter pf = AuthorityRoleDAOManager.getAuthControlFilter(false); // if (pf != null && // !ComparatorUtils.equals(oldName, currentText)) { // try { // Iterator iterator = AuthorityRoleDAOManager.authorityAllocationIterator(pf); // // while (iterator.hasNext()) { // AuthorityAllocation authorityAllocation = (AuthorityAllocation) ((Map.Entry) iterator.next()) // .getValue(); // Authority _authority = authorityAllocation.getAuthority(); // if(ComparatorUtils.equals(_authority.getName(), currentText)){ // isContained = true; // break; // } // } // } catch (Exception e) { // } // } // // if (currentText.isEmpty() || isContained) { // JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("RoleName_Can_Not_Be_Null") + "!"); // roleTree.refreshTreeNode(); // expandTree(roleTree, true); // delegate.setValue(oldName); // return false; // } // return true; // } // // /* // * 下面两个方法是CellEditorListener的 // */ // @Override // public void editingCanceled(ChangeEvent e) { // if (!checkRoleNameNotEmpty()) { // treePath = null; // return; // } // roleTree.stopEditing(); // if (treePath == null) { // return; // } // changeValue(); // roleTree.refreshTreeNode(); // expandTree(roleTree, true); // } // // @Override // public void editingStopped(ChangeEvent e) { // if (!checkRoleNameNotEmpty()) { // treePath = null; // return; // } // changeValue(); // roleTree.refreshTreeNode(); // expandTree(roleTree, true); // roleTree.updateUI(); // } // // private void changeValue() { // newName = delegate.getCellEditorValue().toString(); // if (!newName.isEmpty() && newName != oldName) { // roleTree.setSelectedRoleName(newName); // op.rename(oldName, newName); // // AuthorityControlFilter pf = AuthorityRoleDAOManager.getAuthControlFilter(false); // if (pf != null) { // try { // Iterator iterator = AuthorityRoleDAOManager.authorityAllocationIterator(pf); // // while (iterator.hasNext()) { // AuthorityAllocation authorityAllocation = (AuthorityAllocation) ((Map.Entry) iterator.next()) // .getValue(); // Authority _authority = authorityAllocation.getAuthority(); // if (ComparatorUtils.equals(_authority.getName(), oldName)) { // _authority.setName(newName); // } // } // } catch (Exception e) { // } // } // // try { // AuthorityRoleDAOManager.doEnd(pf); // } catch (Exception e) { // FRContext.getLogger().error(e.getMessage(), e); // } // } // } // } /** * 展开树 * @param tree 树 * @param isExpand 是否展开 */ public void expandTree(JTree tree, boolean isExpand) { TreeNode root = (TreeNode) tree.getModel().getRoot(); expandAll(tree, new TreePath(root), isExpand); } private void expandAll(JTree tree, TreePath parent, boolean expand) { TreeNode node = (TreeNode) parent.getLastPathComponent(); if (node.getChildCount() >= 0) { for (Enumeration e = node.children(); e.hasMoreElements(); ) { TreeNode n = (TreeNode) e.nextElement(); TreePath path = parent.pathByAddingChild(n); expandAll(tree, path, expand); } } if (expand) { tree.expandPath(parent); } else { tree.collapsePath(parent); } } } \ No newline at end of file From a67e88d662297a5f2846a49244f0c075bcf0779e Mon Sep 17 00:00:00 2001 From: juhaoyu <2335173323@qq.com> Date: Wed, 13 Sep 2017 18:48:13 +0800 Subject: [PATCH 21/22] fix --- .../roleAuthority/ReportAndFSManagePane.java | 541 +++++++++++++++++- 1 file changed, 540 insertions(+), 1 deletion(-) diff --git a/designer_base/src/com/fr/design/roleAuthority/ReportAndFSManagePane.java b/designer_base/src/com/fr/design/roleAuthority/ReportAndFSManagePane.java index 98c570786..2c332c312 100644 --- a/designer_base/src/com/fr/design/roleAuthority/ReportAndFSManagePane.java +++ b/designer_base/src/com/fr/design/roleAuthority/ReportAndFSManagePane.java @@ -1 +1,540 @@ -package com.fr.design.roleAuthority; import com.fr.base.BaseUtils; import com.fr.base.FRCoreContext; import com.fr.design.actions.UpdateAction; import com.fr.design.constants.UIConstants; import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.tabledata.Prepare4DataSourceChange; import com.fr.design.gui.ibutton.UIHeadGroup; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.itoolbar.UIToolbar; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DockingView; import com.fr.design.menu.ToolBarDef; import com.fr.general.Inter; import com.fr.general.VT4FR; import javax.swing.*; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.event.TreeSelectionEvent; import javax.swing.tree.TreeNode; import javax.swing.tree.TreePath; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.util.Enumeration; /** * 设计器左下角面板,用于在权限编辑时存放角色 * Author : daisy * Date: 13-8-30 * Time: 下午2:22 */ public class ReportAndFSManagePane extends DockingView implements Prepare4DataSourceChange { private static final int REPORT_PLATEFORM_MANAGE = 0; private static final int FS_MANAGE = 1; private static final int LEFT_GAP = -125; private static boolean isSupportFS = false; private TreePath treePath = null; private static ReportAndFSManagePane singleton = new ReportAndFSManagePane(); private static RoleTree roleTree; // carl:我先屏了,现在半拉子,等客户要了再好好做 // private AddAction addAction = new AddAction(); // private RemoveAction removeAction = new RemoveAction(); private RefreshAction refreshAction = new RefreshAction(); private UIHeadGroup buttonGroup; private RoleSourceOP op; protected String[] roleNames = new String[2]; public synchronized static ReportAndFSManagePane getInstance() { singleton.op = new RoleSourceOP(); singleton.op.setDataMode(isSupportFS ? FS_MANAGE : REPORT_PLATEFORM_MANAGE); singleton.setDefaultSelectedRole(); return singleton; } public ReportAndFSManagePane() { initRoleTree(); this.setLayout(new BorderLayout(4, 0)); this.setBorder(null); this.add(iniToolBarPane(), BorderLayout.NORTH); refreshAction.setEnabled(true); UIScrollPane scrollPane = new UIScrollPane(roleTree); scrollPane.setBorder(BorderFactory.createEmptyBorder(0, 24, 0, 0)); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); initbuttonGroup(); JPanel jPanel = new JPanel(new BorderLayout(4, 4)); JPanel buttonPane = new JPanel(new GridLayout()); buttonPane.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, UIConstants.LINE_COLOR)); buttonPane.add(buttonGroup, BorderLayout.CENTER); jPanel.add(buttonPane, BorderLayout.NORTH); jPanel.add(scrollPane, BorderLayout.CENTER); this.add(jPanel, BorderLayout.CENTER); registerDSChangeListener(); } private void initRoleTree() { roleTree = new RoleTree() { public void refreshRoleTree(String selectedRole) { super.refreshRoleTree(selectedRole); changeAlreadyEditedPaneRole(selectedRole); } protected void doWithValueChanged(TreeSelectionEvent e) { super.doWithValueChanged(e); TreeNode root = (TreeNode) roleTree.getModel().getRoot(); TreePath parent = new TreePath(root); setSelectedRole(roleTree.getSelectedRoleName(), parent); } protected void setTabRoleName(String roleName) { roleNames[getMode()] = roleTree.getSelectedRoleName(); } }; roleTree.setEnabled(true); roleTree.setEditable(false); // RoleTreeCellEditor treeCellEditor = new RoleTreeCellEditor(new UITextField()); // treeCellEditor.addCellEditorListener(treeCellEditor); // roleTree.setCellEditor(treeCellEditor); roleTree.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { super.mouseClicked(e); roleTree.setEditable(false); // int row = roleTree.getRowForLocation(e.getX(), e.getY()); // TreePath path = roleTree.getPathForLocation(e.getX(), e.getY()); // if (e.getClickCount() == 2 && buttonGroup.getSelectedIndex() == REPORT_PLATEFORM_MANAGE) { // PrivilegeManagerProvider pm = PrivilegeManager.getProviderInstance(); // AuthenticationProvider ap = pm.getAuthenticationProvider(); // if (!(ap instanceof DaoAuthenticationProvider)) { // roleTree.setEditable(true); // roleTree.startEditingAtPath(path); // treePath = path; // } // } } }); } private void changeAlreadyEditedPaneRole(String selectedRole) { RolesAlreadyEditedPane.getInstance().refreshDockingView(); RoleTree roleTree = RolesAlreadyEditedPane.getInstance().getRoleTree(); TreeNode root = (TreeNode) roleTree.getModel().getRoot(); TreePath parent = new TreePath(root); roleTree.setSelectedRole(selectedRole, parent); } public void setDefaultSelectedRole() { //设置选中的节点 TreeNode root = (TreeNode) roleTree.getModel().getRoot(); TreePath parent = new TreePath(root); ExpandMutableTreeNode node = (ExpandMutableTreeNode) parent.getLastPathComponent(); String selectedRole = null; if (singleton != null) { selectedRole = roleNames[getMode()]; } if (selectedRole == null) { if (node.getChildCount() <= 0 || node.getFirstChild().getChildCount() <= 0) { return; } selectedRole = node.getFirstChild().getChildAt(0).toString(); } roleTree.setSelectedRole(selectedRole, parent); } public RoleTree getRoleTree() { return roleTree; } /** * 检查f) 每增删改一个角色信息(及时保存),先对比下privilege下之前的角色信息有没有发生变化(即在此期间有没有在其他途径中修改过) */ private void checkChanges() { //如若有变化,则弹出下面的对话框 int returnVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("FR-Designer_Role_changed_isRefresh") + "?", Inter.getLocText("FR-Designer_Refresh"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE); if (returnVal == JOptionPane.OK_OPTION) { roleTree.refreshTreeNode(); expandTree(roleTree, true); roleTree.updateUI(); } } private JPanel iniToolBarPane() { ToolBarDef toolbarDef = new ToolBarDef(); toolbarDef.addShortCut(refreshAction); UIToolbar toolBar = ToolBarDef.createJToolBar(); toolbarDef.updateToolBar(toolBar); JPanel toolbarPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); toolbarPane.add(toolBar, BorderLayout.CENTER); return toolbarPane; } private void initbuttonGroup() { Icon[] iconArray = new Icon[]{BaseUtils.readIcon("/com/fr/web/images/platform/demo.png")}; String[] textArray = new String[]{Inter.getLocText("FR-Designer_FS_Name")}; buttonGroup = new UIHeadGroup(iconArray, textArray) { public void tabChanged(int index) { roleTree.setEditable(false); if (op != null) { op.setDataMode(getMode()); //判断是否可编辑 refreshDockingView(); } setDefaultSelectedRole(); if (singleton != null) { changeAlreadyEditedPaneRole(roleNames[getMode()]); } } }; buttonGroup.setBorder(BorderFactory.createMatteBorder(1, LEFT_GAP, 0, 0, UIConstants.LINE_COLOR)); buttonGroup.setNeedLeftRightOutLine(false); } private int getMode(){ return isSupportFS?FS_MANAGE: REPORT_PLATEFORM_MANAGE; } // /** // * 检查看看是否可以增删刷新按钮是都可以编辑,并且检查角色树是不是可以编辑 // */ // public void checkToolButtonsEnabled() { // if (buttonGroup.getSelectedIndex() == REPORT_PLATEFORM_MANAGE) { // PrivilegeManagerProvider pm = PrivilegeManager.getProviderInstance(); // AuthenticationProvider ap = pm.getAuthenticationProvider(); // PrivilegeFilter pf = pm.getPrivilegeFilter(); // boolean isClickable = !(ap instanceof DaoAuthenticationProvider) // && pf instanceof AuthorityControlFilter; // addAction.setEnabled(isClickable); // removeAction.setEnabled(isClickable); // } else { // addAction.setEnabled(false); // removeAction.setEnabled(false); // } // // } /** * 刷新界面 */ public void refreshDockingView() { populate(new RoleSourceOP()); // this.checkToolButtonsEnabled(); } private void populate(RoleSourceOP op) { this.op = op; roleTree.populate(op); expandTree(roleTree, true); } public String getViewTitle() { return null; } public Icon getViewIcon() { return null; } /** * 最佳定位 * @return 定位 */ public Location preferredLocation() { return null; } /** * 注册数据库改变的响应的Listener */ public void registerDSChangeListener() { DesignTableDataManager.addDsChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { roleTree.refreshTreeNode(); expandTree(roleTree, true); roleTree.updateUI(); } }); } // private class AddAction extends UpdateAction { // public AddAction() { // this.setName(Inter.getLocText("Add")); // this.setSmallIcon(BaseUtils.readIcon("/com/fr/base/images/cell/control/add.png")); // } // // @Override // public void actionPerformed(ActionEvent e) { // refreshDockingView(); // // DefaultTreeModel treeModel = (DefaultTreeModel) roleTree.getModel(); // ExpandMutableTreeNode root = (ExpandMutableTreeNode) treeModel.getRoot(); // ExpandMutableTreeNode parentNode = (ExpandMutableTreeNode) root.getChildAt(0); // String newName = Inter.getLocText("newNode") + (++newIndex); // parentNode.add(new ExpandMutableTreeNode(newName)); // op.addAction(newName); // roleTree.updateUI(); // // try { // synchronized (AuthorityRoleDAOManager.class) { // AuthorityControlFilter pf = AuthorityRoleDAOManager.getAuthControlFilter(true); // // if (AuthorityRoleDAOManager.getAuthorityAllocation(pf, newName) != null) { // newName = Inter.getLocText("newNode") + (++newIndex); // roleTree.refreshTreeNode(); // expandTree(roleTree, true); // } // // AuthorityRoleDAOManager.addAuthorityRole(pf, new Authority(newName), new Allocation(), false, true); // // AuthorityRoleDAOManager.doEnd(pf); // } // } catch (Exception e1) { // FRContext.getLogger().error(e1.getMessage(), e1); // } // } // } // private class RemoveAction extends UpdateAction { // // public RemoveAction() { // this.setName(Inter.getLocText("Remove")); // this.setSmallIcon(UIConstants.CLEAR_ICON); // } // // @Override // public void actionPerformed(ActionEvent e) { // // // NameObject selectedNO = roleTree.getSelectedNameObject(); // // if (selectedNO == null) { // return; // } // // int returnVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("Utils-Are_you_sure_to_remove_the_selected_item") + ":" + selectedNO.getName() + "?", // Inter.getLocText("Remove"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); // if (returnVal == JOptionPane.OK_OPTION) { // op.removeAction(selectedNO.getName()); // // try { // AuthorityControlFilter pf = AuthorityRoleDAOManager.getAuthControlFilter(true); // // AuthorityRoleDAOManager.removeAuthorityRole(pf, new Authority(selectedNO.getName()), true); // AuthorityRoleDAOManager.doEnd(pf); // } catch (Exception e1) { // FRContext.getLogger().error(e1.getMessage(), e1); // } // // roleTree.refreshTreeNode(); // expandTree(roleTree, true); // roleTree.updateUI(); // roleTree.requestFocus(); // roleTree.setSelectionRow(roleTree.getRowCount() - 1); // } // } // } /* * 刷新ReportletsTree */ private class RefreshAction extends UpdateAction { public RefreshAction() { this.setName(Inter.getLocText("FR-Designer_Refresh")); this.setSmallIcon(UIConstants.REFRESH_ICON); } @Override public void actionPerformed(ActionEvent evt) { roleTree.refreshTreeNode(); expandTree(roleTree, true); roleTree.updateUI(); } } // private class RoleTreeCellEditor extends DefaultCellEditor implements TreeCellEditor, CellEditorListener { // // private NameObject editingNO; // private String oldName; // private String newName; // private UITextField jTextField; // // public RoleTreeCellEditor(final UITextField textField) { // super(textField); // this.jTextField = textField; // this.jTextField.setPreferredSize(new Dimension(DesignerEnvManager.getEnvManager().getLastWestRegionContainerWidth() - 5, this.jTextField.getHeight())); // } // // @Override // public Component getTreeCellEditorComponent(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row) { // editingNO = ReportAndFSManagePane.this.roleTree.getSelectedNameObject(); // oldName = editingNO.getName(); // // delegate.setValue(oldName); // // editorComponent.setPreferredSize(new java.awt.Dimension(ReportAndFSManagePane.this.getPreferredSize().width, editorComponent.getPreferredSize().height)); // // return editorComponent; // } // // @Override // // public boolean isCellEditable(EventObject anEvent) { // NameObject no = ReportAndFSManagePane.this.roleTree.getSelectedNameObject(); // return !(no.getName() == Inter.getLocText("Role")); // } // // @Override // public Object getCellEditorValue() { // newName = super.getCellEditorValue().toString(); // editingNO.setName(newName); // return editingNO; // } // // // private boolean checkRoleNameNotEmpty() { // refreshDockingView(); // // String currentText = delegate.getCellEditorValue().toString(); // boolean isContained = false; // AuthorityControlFilter pf = AuthorityRoleDAOManager.getAuthControlFilter(false); // if (pf != null && // !ComparatorUtils.equals(oldName, currentText)) { // try { // Iterator iterator = AuthorityRoleDAOManager.authorityAllocationIterator(pf); // // while (iterator.hasNext()) { // AuthorityAllocation authorityAllocation = (AuthorityAllocation) ((Map.Entry) iterator.next()) // .getValue(); // Authority _authority = authorityAllocation.getAuthority(); // if(ComparatorUtils.equals(_authority.getName(), currentText)){ // isContained = true; // break; // } // } // } catch (Exception e) { // } // } // // if (currentText.isEmpty() || isContained) { // JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("RoleName_Can_Not_Be_Null") + "!"); // roleTree.refreshTreeNode(); // expandTree(roleTree, true); // delegate.setValue(oldName); // return false; // } // return true; // } // // /* // * 下面两个方法是CellEditorListener的 // */ // @Override // public void editingCanceled(ChangeEvent e) { // if (!checkRoleNameNotEmpty()) { // treePath = null; // return; // } // roleTree.stopEditing(); // if (treePath == null) { // return; // } // changeValue(); // roleTree.refreshTreeNode(); // expandTree(roleTree, true); // } // // @Override // public void editingStopped(ChangeEvent e) { // if (!checkRoleNameNotEmpty()) { // treePath = null; // return; // } // changeValue(); // roleTree.refreshTreeNode(); // expandTree(roleTree, true); // roleTree.updateUI(); // } // // private void changeValue() { // newName = delegate.getCellEditorValue().toString(); // if (!newName.isEmpty() && newName != oldName) { // roleTree.setSelectedRoleName(newName); // op.rename(oldName, newName); // // AuthorityControlFilter pf = AuthorityRoleDAOManager.getAuthControlFilter(false); // if (pf != null) { // try { // Iterator iterator = AuthorityRoleDAOManager.authorityAllocationIterator(pf); // // while (iterator.hasNext()) { // AuthorityAllocation authorityAllocation = (AuthorityAllocation) ((Map.Entry) iterator.next()) // .getValue(); // Authority _authority = authorityAllocation.getAuthority(); // if (ComparatorUtils.equals(_authority.getName(), oldName)) { // _authority.setName(newName); // } // } // } catch (Exception e) { // } // } // // try { // AuthorityRoleDAOManager.doEnd(pf); // } catch (Exception e) { // FRContext.getLogger().error(e.getMessage(), e); // } // } // } // } /** * 展开树 * @param tree 树 * @param isExpand 是否展开 */ public void expandTree(JTree tree, boolean isExpand) { TreeNode root = (TreeNode) tree.getModel().getRoot(); expandAll(tree, new TreePath(root), isExpand); } private void expandAll(JTree tree, TreePath parent, boolean expand) { TreeNode node = (TreeNode) parent.getLastPathComponent(); if (node.getChildCount() >= 0) { for (Enumeration e = node.children(); e.hasMoreElements(); ) { TreeNode n = (TreeNode) e.nextElement(); TreePath path = parent.pathByAddingChild(n); expandAll(tree, path, expand); } } if (expand) { tree.expandPath(parent); } else { tree.collapsePath(parent); } } } \ No newline at end of file +package com.fr.design.roleAuthority; + +import com.fr.base.BaseUtils; +import com.fr.base.FRCoreContext; +import com.fr.design.actions.UpdateAction; +import com.fr.design.constants.UIConstants; +import com.fr.design.data.DesignTableDataManager; +import com.fr.design.data.tabledata.Prepare4DataSourceChange; +import com.fr.design.gui.ibutton.UIHeadGroup; +import com.fr.design.gui.icontainer.UIScrollPane; +import com.fr.design.gui.itoolbar.UIToolbar; +import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.DockingView; +import com.fr.design.menu.ToolBarDef; +import com.fr.general.Inter; +import com.fr.general.VT4FR; + +import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import javax.swing.event.TreeSelectionEvent; +import javax.swing.tree.TreeNode; +import javax.swing.tree.TreePath; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.Enumeration; + +/** + * 设计器左下角面板,用于在权限编辑时存放角色 + * Author : daisy + * Date: 13-8-30 + * Time: 下午2:22 + */ +public class ReportAndFSManagePane extends DockingView implements Prepare4DataSourceChange { + + private static final int REPORT_PLATEFORM_MANAGE = 0; + private static final int FS_MANAGE = 1; + private static final int LEFT_GAP = -125; + private static boolean isSupportFS = false; + private TreePath treePath = null; + + private static ReportAndFSManagePane singleton = new ReportAndFSManagePane(); + + private static RoleTree roleTree; + // carl:我先屏了,现在半拉子,等客户要了再好好做 +// private AddAction addAction = new AddAction(); +// private RemoveAction removeAction = new RemoveAction(); + private RefreshAction refreshAction = new RefreshAction(); + private UIHeadGroup buttonGroup; + private RoleSourceOP op; + protected String[] roleNames = new String[2]; + + public synchronized static ReportAndFSManagePane getInstance() { + singleton.op = new RoleSourceOP(); + singleton.op.setDataMode(isSupportFS ? FS_MANAGE : REPORT_PLATEFORM_MANAGE); + singleton.setDefaultSelectedRole(); + return singleton; + + } + + public ReportAndFSManagePane() { + initRoleTree(); + this.setLayout(new BorderLayout(4, 0)); + this.setBorder(null); + this.add(iniToolBarPane(), BorderLayout.NORTH); + refreshAction.setEnabled(true); + UIScrollPane scrollPane = new UIScrollPane(roleTree); + scrollPane.setBorder(BorderFactory.createEmptyBorder(0, 24, 0, 0)); + scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); + scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); + initbuttonGroup(); + JPanel jPanel = new JPanel(new BorderLayout(4, 4)); + JPanel buttonPane = new JPanel(new GridLayout()); + buttonPane.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, UIConstants.LINE_COLOR)); + buttonPane.add(buttonGroup, BorderLayout.CENTER); + jPanel.add(buttonPane, BorderLayout.NORTH); + jPanel.add(scrollPane, BorderLayout.CENTER); + this.add(jPanel, BorderLayout.CENTER); + registerDSChangeListener(); + } + + private void initRoleTree() { + roleTree = new RoleTree() { + public void refreshRoleTree(String selectedRole) { + super.refreshRoleTree(selectedRole); + changeAlreadyEditedPaneRole(selectedRole); + } + + + protected void doWithValueChanged(TreeSelectionEvent e) { + super.doWithValueChanged(e); + TreeNode root = (TreeNode) roleTree.getModel().getRoot(); + TreePath parent = new TreePath(root); + setSelectedRole(roleTree.getSelectedRoleName(), parent); + + } + + protected void setTabRoleName(String roleName) { + roleNames[getMode()] = roleTree.getSelectedRoleName(); + } + }; + roleTree.setEnabled(true); + roleTree.setEditable(false); +// RoleTreeCellEditor treeCellEditor = new RoleTreeCellEditor(new UITextField()); +// treeCellEditor.addCellEditorListener(treeCellEditor); +// roleTree.setCellEditor(treeCellEditor); + roleTree.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + super.mouseClicked(e); + roleTree.setEditable(false); +// int row = roleTree.getRowForLocation(e.getX(), e.getY()); +// TreePath path = roleTree.getPathForLocation(e.getX(), e.getY()); +// if (e.getClickCount() == 2 && buttonGroup.getSelectedIndex() == REPORT_PLATEFORM_MANAGE) { +// PrivilegeManagerProvider pm = PrivilegeManager.getProviderInstance(); +// AuthenticationProvider ap = pm.getAuthenticationProvider(); +// if (!(ap instanceof DaoAuthenticationProvider)) { +// roleTree.setEditable(true); +// roleTree.startEditingAtPath(path); +// treePath = path; +// } +// } + } + }); + } + + private void changeAlreadyEditedPaneRole(String selectedRole) { + RolesAlreadyEditedPane.getInstance().refreshDockingView(); + RoleTree roleTree = RolesAlreadyEditedPane.getInstance().getRoleTree(); + TreeNode root = (TreeNode) roleTree.getModel().getRoot(); + TreePath parent = new TreePath(root); + roleTree.setSelectedRole(selectedRole, parent); + } + + public void setDefaultSelectedRole() { + //设置选中的节点 + TreeNode root = (TreeNode) roleTree.getModel().getRoot(); + TreePath parent = new TreePath(root); + ExpandMutableTreeNode node = (ExpandMutableTreeNode) parent.getLastPathComponent(); + String selectedRole = null; + if (singleton != null) { + selectedRole = roleNames[getMode()]; + } + if (selectedRole == null) { + if (node.getChildCount() <= 0 || node.getFirstChild().getChildCount() <= 0) { + return; + } + selectedRole = node.getFirstChild().getChildAt(0).toString(); + } + roleTree.setSelectedRole(selectedRole, parent); + } + + + public RoleTree getRoleTree() { + return roleTree; + } + + /** + * 检查f) 每增删改一个角色信息(及时保存),先对比下privilege下之前的角色信息有没有发生变化(即在此期间有没有在其他途径中修改过) + */ + private void checkChanges() { + //如若有变化,则弹出下面的对话框 + int returnVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("FR-Designer_Role_changed_isRefresh") + "?", + Inter.getLocText("FR-Designer_Refresh"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE); + if (returnVal == JOptionPane.OK_OPTION) { + roleTree.refreshTreeNode(); + expandTree(roleTree, true); + roleTree.updateUI(); + } + + } + + private JPanel iniToolBarPane() { + ToolBarDef toolbarDef = new ToolBarDef(); + toolbarDef.addShortCut(refreshAction); + UIToolbar toolBar = ToolBarDef.createJToolBar(); + toolbarDef.updateToolBar(toolBar); + JPanel toolbarPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + toolbarPane.add(toolBar, BorderLayout.CENTER); + return toolbarPane; + } + + private void initbuttonGroup() { + Icon[] iconArray = new Icon[]{BaseUtils.readIcon("/com/fr/web/images/platform/demo.png")}; + String[] textArray = new String[]{Inter.getLocText("FR-Designer_FS_Name")}; + buttonGroup = new UIHeadGroup(iconArray, textArray) { + public void tabChanged(int index) { + roleTree.setEditable(false); + if (op != null) { + op.setDataMode(getMode()); + //判断是否可编辑 + refreshDockingView(); + } + setDefaultSelectedRole(); + if (singleton != null) { + changeAlreadyEditedPaneRole(roleNames[getMode()]); + } + } + }; + buttonGroup.setBorder(BorderFactory.createMatteBorder(1, LEFT_GAP, 0, 0, UIConstants.LINE_COLOR)); + buttonGroup.setNeedLeftRightOutLine(false); + } + + + private int getMode(){ + return isSupportFS?FS_MANAGE: REPORT_PLATEFORM_MANAGE; + } + + +// /** +// * 检查看看是否可以增删刷新按钮是都可以编辑,并且检查角色树是不是可以编辑 +// */ +// public void checkToolButtonsEnabled() { +// if (buttonGroup.getSelectedIndex() == REPORT_PLATEFORM_MANAGE) { +// PrivilegeManagerProvider pm = PrivilegeManager.getProviderInstance(); +// AuthenticationProvider ap = pm.getAuthenticationProvider(); +// PrivilegeFilter pf = pm.getPrivilegeFilter(); +// boolean isClickable = !(ap instanceof DaoAuthenticationProvider) +// && pf instanceof AuthorityControlFilter; +// addAction.setEnabled(isClickable); +// removeAction.setEnabled(isClickable); +// } else { +// addAction.setEnabled(false); +// removeAction.setEnabled(false); +// } +// +// } + + + /** + * 刷新界面 + */ + public void refreshDockingView() { + populate(new RoleSourceOP()); +// this.checkToolButtonsEnabled(); + } + + private void populate(RoleSourceOP op) { + this.op = op; + roleTree.populate(op); + expandTree(roleTree, true); + } + + public String getViewTitle() { + return null; + } + + public Icon getViewIcon() { + return null; + } + + /** + * 最佳定位 + * @return 定位 + */ + public Location preferredLocation() { + return null; + } + + /** + * 注册数据库改变的响应的Listener + */ + public void registerDSChangeListener() { + DesignTableDataManager.addDsChangeListener(new ChangeListener() { + + public void stateChanged(ChangeEvent e) { + roleTree.refreshTreeNode(); + expandTree(roleTree, true); + roleTree.updateUI(); + } + }); + + } + +// private class AddAction extends UpdateAction { +// public AddAction() { +// this.setName(Inter.getLocText("Add")); +// this.setSmallIcon(BaseUtils.readIcon("/com/fr/base/images/cell/control/add.png")); +// } +// +// @Override +// public void actionPerformed(ActionEvent e) { +// refreshDockingView(); +// +// DefaultTreeModel treeModel = (DefaultTreeModel) roleTree.getModel(); +// ExpandMutableTreeNode root = (ExpandMutableTreeNode) treeModel.getRoot(); +// ExpandMutableTreeNode parentNode = (ExpandMutableTreeNode) root.getChildAt(0); +// String newName = Inter.getLocText("newNode") + (++newIndex); +// parentNode.add(new ExpandMutableTreeNode(newName)); +// op.addAction(newName); +// roleTree.updateUI(); +// +// try { +// synchronized (AuthorityRoleDAOManager.class) { +// AuthorityControlFilter pf = AuthorityRoleDAOManager.getAuthControlFilter(true); +// +// if (AuthorityRoleDAOManager.getAuthorityAllocation(pf, newName) != null) { +// newName = Inter.getLocText("newNode") + (++newIndex); +// roleTree.refreshTreeNode(); +// expandTree(roleTree, true); +// } +// +// AuthorityRoleDAOManager.addAuthorityRole(pf, new Authority(newName), new Allocation(), false, true); +// +// AuthorityRoleDAOManager.doEnd(pf); +// } +// } catch (Exception e1) { +// FRContext.getLogger().error(e1.getMessage(), e1); +// } +// } +// } + +// private class RemoveAction extends UpdateAction { +// +// public RemoveAction() { +// this.setName(Inter.getLocText("Remove")); +// this.setSmallIcon(UIConstants.CLEAR_ICON); +// } +// +// @Override +// public void actionPerformed(ActionEvent e) { +// +// +// NameObject selectedNO = roleTree.getSelectedNameObject(); +// +// if (selectedNO == null) { +// return; +// } +// +// int returnVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("Utils-Are_you_sure_to_remove_the_selected_item") + ":" + selectedNO.getName() + "?", +// Inter.getLocText("Remove"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); +// if (returnVal == JOptionPane.OK_OPTION) { +// op.removeAction(selectedNO.getName()); +// +// try { +// AuthorityControlFilter pf = AuthorityRoleDAOManager.getAuthControlFilter(true); +// +// AuthorityRoleDAOManager.removeAuthorityRole(pf, new Authority(selectedNO.getName()), true); +// AuthorityRoleDAOManager.doEnd(pf); +// } catch (Exception e1) { +// FRContext.getLogger().error(e1.getMessage(), e1); +// } +// +// roleTree.refreshTreeNode(); +// expandTree(roleTree, true); +// roleTree.updateUI(); +// roleTree.requestFocus(); +// roleTree.setSelectionRow(roleTree.getRowCount() - 1); +// } +// } +// } + + + /* + * 刷新ReportletsTree + */ + private class RefreshAction extends UpdateAction { + + public RefreshAction() { + this.setName(Inter.getLocText("FR-Designer_Refresh")); + this.setSmallIcon(UIConstants.REFRESH_ICON); + } + + @Override + public void actionPerformed(ActionEvent evt) { + roleTree.refreshTreeNode(); + expandTree(roleTree, true); + roleTree.updateUI(); + } + } + + +// private class RoleTreeCellEditor extends DefaultCellEditor implements TreeCellEditor, CellEditorListener { +// +// private NameObject editingNO; +// private String oldName; +// private String newName; +// private UITextField jTextField; +// +// public RoleTreeCellEditor(final UITextField textField) { +// super(textField); +// this.jTextField = textField; +// this.jTextField.setPreferredSize(new Dimension(DesignerEnvManager.getEnvManager().getLastWestRegionContainerWidth() - 5, this.jTextField.getHeight())); +// } +// +// @Override +// public Component getTreeCellEditorComponent(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row) { +// editingNO = ReportAndFSManagePane.this.roleTree.getSelectedNameObject(); +// oldName = editingNO.getName(); +// +// delegate.setValue(oldName); +// +// editorComponent.setPreferredSize(new java.awt.Dimension(ReportAndFSManagePane.this.getPreferredSize().width, editorComponent.getPreferredSize().height)); +// +// return editorComponent; +// } +// +// @Override +// +// public boolean isCellEditable(EventObject anEvent) { +// NameObject no = ReportAndFSManagePane.this.roleTree.getSelectedNameObject(); +// return !(no.getName() == Inter.getLocText("Role")); +// } +// +// @Override +// public Object getCellEditorValue() { +// newName = super.getCellEditorValue().toString(); +// editingNO.setName(newName); +// return editingNO; +// } +// +// +// private boolean checkRoleNameNotEmpty() { +// refreshDockingView(); +// +// String currentText = delegate.getCellEditorValue().toString(); +// boolean isContained = false; +// AuthorityControlFilter pf = AuthorityRoleDAOManager.getAuthControlFilter(false); +// if (pf != null && +// !ComparatorUtils.equals(oldName, currentText)) { +// try { +// Iterator iterator = AuthorityRoleDAOManager.authorityAllocationIterator(pf); +// +// while (iterator.hasNext()) { +// AuthorityAllocation authorityAllocation = (AuthorityAllocation) ((Map.Entry) iterator.next()) +// .getValue(); +// Authority _authority = authorityAllocation.getAuthority(); +// if(ComparatorUtils.equals(_authority.getName(), currentText)){ +// isContained = true; +// break; +// } +// } +// } catch (Exception e) { +// } +// } +// +// if (currentText.isEmpty() || isContained) { +// JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("RoleName_Can_Not_Be_Null") + "!"); +// roleTree.refreshTreeNode(); +// expandTree(roleTree, true); +// delegate.setValue(oldName); +// return false; +// } +// return true; +// } +// +// /* +// * 下面两个方法是CellEditorListener的 +// */ +// @Override +// public void editingCanceled(ChangeEvent e) { +// if (!checkRoleNameNotEmpty()) { +// treePath = null; +// return; +// } +// roleTree.stopEditing(); +// if (treePath == null) { +// return; +// } +// changeValue(); +// roleTree.refreshTreeNode(); +// expandTree(roleTree, true); +// } +// +// @Override +// public void editingStopped(ChangeEvent e) { +// if (!checkRoleNameNotEmpty()) { +// treePath = null; +// return; +// } +// changeValue(); +// roleTree.refreshTreeNode(); +// expandTree(roleTree, true); +// roleTree.updateUI(); +// } +// +// private void changeValue() { +// newName = delegate.getCellEditorValue().toString(); +// if (!newName.isEmpty() && newName != oldName) { +// roleTree.setSelectedRoleName(newName); +// op.rename(oldName, newName); +// +// AuthorityControlFilter pf = AuthorityRoleDAOManager.getAuthControlFilter(false); +// if (pf != null) { +// try { +// Iterator iterator = AuthorityRoleDAOManager.authorityAllocationIterator(pf); +// +// while (iterator.hasNext()) { +// AuthorityAllocation authorityAllocation = (AuthorityAllocation) ((Map.Entry) iterator.next()) +// .getValue(); +// Authority _authority = authorityAllocation.getAuthority(); +// if (ComparatorUtils.equals(_authority.getName(), oldName)) { +// _authority.setName(newName); +// } +// } +// } catch (Exception e) { +// } +// } +// +// try { +// AuthorityRoleDAOManager.doEnd(pf); +// } catch (Exception e) { +// FRContext.getLogger().error(e.getMessage(), e); +// } +// } +// } +// } + + + /** + * 展开树 + * @param tree 树 + * @param isExpand 是否展开 + */ + public void expandTree(JTree tree, boolean isExpand) { + TreeNode root = (TreeNode) tree.getModel().getRoot(); + expandAll(tree, new TreePath(root), isExpand); + } + + + private void expandAll(JTree tree, TreePath parent, boolean expand) { + TreeNode node = (TreeNode) parent.getLastPathComponent(); + if (node.getChildCount() >= 0) { + for (Enumeration e = node.children(); e.hasMoreElements(); ) { + TreeNode n = (TreeNode) e.nextElement(); + TreePath path = parent.pathByAddingChild(n); + expandAll(tree, path, expand); + } + } + if (expand) { + tree.expandPath(parent); + } else { + tree.collapsePath(parent); + } + } + +} \ No newline at end of file From 2d030e08f717cfba98a58e80cd9e3dfe4c72f1f7 Mon Sep 17 00:00:00 2001 From: juhaoyu <2335173323@qq.com> Date: Wed, 13 Sep 2017 18:49:03 +0800 Subject: [PATCH 22/22] =?UTF-8?q?PFC-607=20=E6=8F=92=E4=BB=B6=E5=AE=89?= =?UTF-8?q?=E8=A3=85=E5=88=A0=E9=99=A4=E6=9B=B4=E6=96=B0=E4=B8=8D=E9=87=8D?= =?UTF-8?q?=E5=90=AF=E6=94=AF=E6=8C=81=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../roleAuthority/ReportAndFSManagePane.java | 540 +++++++++++++++++- 1 file changed, 539 insertions(+), 1 deletion(-) diff --git a/designer_base/src/com/fr/design/roleAuthority/ReportAndFSManagePane.java b/designer_base/src/com/fr/design/roleAuthority/ReportAndFSManagePane.java index 9f351fb57..3419b8560 100644 --- a/designer_base/src/com/fr/design/roleAuthority/ReportAndFSManagePane.java +++ b/designer_base/src/com/fr/design/roleAuthority/ReportAndFSManagePane.java @@ -1 +1,539 @@ -package com.fr.design.roleAuthority; import com.fr.base.BaseUtils; import com.fr.base.FRCoreContext; import com.fr.design.actions.UpdateAction; import com.fr.design.constants.UIConstants; import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.tabledata.Prepare4DataSourceChange; import com.fr.design.gui.ibutton.UIHeadGroup; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.itoolbar.UIToolbar; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DockingView; import com.fr.design.menu.ToolBarDef; import com.fr.general.Inter; import com.fr.general.VT4FR; import javax.swing.*; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.event.TreeSelectionEvent; import javax.swing.tree.TreeNode; import javax.swing.tree.TreePath; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.util.Enumeration; /** * 设计器左下角面板,用于在权限编辑时存放角色 * Author : daisy * Date: 13-8-30 * Time: 下午2:22 */ public class ReportAndFSManagePane extends DockingView implements Prepare4DataSourceChange { private static final int REPORT_PLATEFORM_MANAGE = 0; private static final int FS_MANAGE = 1; private static final int LEFT_GAP = -125; private static boolean isSupportFS = false; private TreePath treePath = null; private static ReportAndFSManagePane singleton = new ReportAndFSManagePane(); private static RoleTree roleTree; // carl:我先屏了,现在半拉子,等客户要了再好好做 // private AddAction addAction = new AddAction(); // private RemoveAction removeAction = new RemoveAction(); private RefreshAction refreshAction = new RefreshAction(); private UIHeadGroup buttonGroup; private RoleSourceOP op; protected String[] roleNames = new String[2]; public synchronized static ReportAndFSManagePane getInstance() { singleton.op = new RoleSourceOP(); singleton.op.setDataMode(isSupportFS ? FS_MANAGE : REPORT_PLATEFORM_MANAGE); singleton.setDefaultSelectedRole(); return singleton; } public ReportAndFSManagePane() { initRoleTree(); this.setLayout(new BorderLayout(4, 0)); this.setBorder(null); this.add(iniToolBarPane(), BorderLayout.NORTH); refreshAction.setEnabled(true); UIScrollPane scrollPane = new UIScrollPane(roleTree); scrollPane.setBorder(BorderFactory.createEmptyBorder(0, 24, 0, 0)); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); initbuttonGroup(); JPanel jPanel = new JPanel(new BorderLayout(4, 4)); JPanel buttonPane = new JPanel(new GridLayout()); buttonPane.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, UIConstants.LINE_COLOR)); buttonPane.add(buttonGroup, BorderLayout.CENTER); jPanel.add(buttonPane, BorderLayout.NORTH); jPanel.add(scrollPane, BorderLayout.CENTER); this.add(jPanel, BorderLayout.CENTER); registerDSChangeListener(); } private void initRoleTree() { roleTree = new RoleTree() { public void refreshRoleTree(String selectedRole) { super.refreshRoleTree(selectedRole); changeAlreadyEditedPaneRole(selectedRole); } protected void doWithValueChanged(TreeSelectionEvent e) { super.doWithValueChanged(e); TreeNode root = (TreeNode) roleTree.getModel().getRoot(); TreePath parent = new TreePath(root); setSelectedRole(roleTree.getSelectedRoleName(), parent); } protected void setTabRoleName(String roleName) { roleNames[getMode()] = roleTree.getSelectedRoleName(); } }; roleTree.setEnabled(true); roleTree.setEditable(false); // RoleTreeCellEditor treeCellEditor = new RoleTreeCellEditor(new UITextField()); // treeCellEditor.addCellEditorListener(treeCellEditor); // roleTree.setCellEditor(treeCellEditor); roleTree.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { super.mouseClicked(e); roleTree.setEditable(false); // int row = roleTree.getRowForLocation(e.getX(), e.getY()); // TreePath path = roleTree.getPathForLocation(e.getX(), e.getY()); // if (e.getClickCount() == 2 && buttonGroup.getSelectedIndex() == REPORT_PLATEFORM_MANAGE) { // PrivilegeManagerProvider pm = PrivilegeManager.getProviderInstance(); // AuthenticationProvider ap = pm.getAuthenticationProvider(); // if (!(ap instanceof DaoAuthenticationProvider)) { // roleTree.setEditable(true); // roleTree.startEditingAtPath(path); // treePath = path; // } // } } }); } private void changeAlreadyEditedPaneRole(String selectedRole) { RolesAlreadyEditedPane.getInstance().refreshDockingView(); RoleTree roleTree = RolesAlreadyEditedPane.getInstance().getRoleTree(); TreeNode root = (TreeNode) roleTree.getModel().getRoot(); TreePath parent = new TreePath(root); roleTree.setSelectedRole(selectedRole, parent); } public void setDefaultSelectedRole() { //设置选中的节点 TreeNode root = (TreeNode) roleTree.getModel().getRoot(); TreePath parent = new TreePath(root); ExpandMutableTreeNode node = (ExpandMutableTreeNode) parent.getLastPathComponent(); String selectedRole = null; if (singleton != null) { selectedRole = roleNames[getMode()]; } if (selectedRole == null) { if (node.getChildCount() <= 0 || node.getFirstChild().getChildCount() <= 0) { return; } selectedRole = node.getFirstChild().getChildAt(0).toString(); } roleTree.setSelectedRole(selectedRole, parent); } public RoleTree getRoleTree() { return roleTree; } /** * 检查f) 每增删改一个角色信息(及时保存),先对比下privilege下之前的角色信息有没有发生变化(即在此期间有没有在其他途径中修改过) */ private void checkChanges() { //如若有变化,则弹出下面的对话框 int returnVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("FR-Designer_Role_changed_isRefresh") + "?", Inter.getLocText("FR-Designer_Refresh"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE); if (returnVal == JOptionPane.OK_OPTION) { roleTree.refreshTreeNode(); expandTree(roleTree, true); roleTree.updateUI(); } } private JPanel iniToolBarPane() { ToolBarDef toolbarDef = new ToolBarDef(); toolbarDef.addShortCut(refreshAction); UIToolbar toolBar = ToolBarDef.createJToolBar(); toolbarDef.updateToolBar(toolBar); JPanel toolbarPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); toolbarPane.add(toolBar, BorderLayout.CENTER); return toolbarPane; } private void initbuttonGroup() { Icon[] iconArray = new Icon[]{BaseUtils.readIcon("/com/fr/web/images/platform/demo.png")}; String[] textArray = new String[]{Inter.getLocText("FR-Designer_FS_Name")}; buttonGroup = new UIHeadGroup(iconArray, textArray) { public void tabChanged(int index) { roleTree.setEditable(false); if (op != null) { op.setDataMode(getMode()); //判断是否可编辑 refreshDockingView(); } setDefaultSelectedRole(); if (singleton != null) { changeAlreadyEditedPaneRole(roleNames[getMode()]); } } }; buttonGroup.setBorder(BorderFactory.createMatteBorder(1, LEFT_GAP, 0, 0, UIConstants.LINE_COLOR)); buttonGroup.setNeedLeftRightOutLine(false); } private int getMode(){ return isSupportFS?FS_MANAGE: REPORT_PLATEFORM_MANAGE; } // /** // * 检查看看是否可以增删刷新按钮是都可以编辑,并且检查角色树是不是可以编辑 // */ // public void checkToolButtonsEnabled() { // if (buttonGroup.getSelectedIndex() == REPORT_PLATEFORM_MANAGE) { // PrivilegeManagerProvider pm = PrivilegeManager.getProviderInstance(); // AuthenticationProvider ap = pm.getAuthenticationProvider(); // PrivilegeFilter pf = pm.getPrivilegeFilter(); // boolean isClickable = !(ap instanceof DaoAuthenticationProvider) // && pf instanceof AuthorityControlFilter; // addAction.setEnabled(isClickable); // removeAction.setEnabled(isClickable); // } else { // addAction.setEnabled(false); // removeAction.setEnabled(false); // } // // } /** * 刷新界面 */ public void refreshDockingView() { populate(new RoleSourceOP()); // this.checkToolButtonsEnabled(); } private void populate(RoleSourceOP op) { this.op = op; roleTree.populate(op); expandTree(roleTree, true); } public String getViewTitle() { return null; } public Icon getViewIcon() { return null; } /** * 最佳定位 * @return 定位 */ public Location preferredLocation() { return null; } /** * 注册数据库改变的响应的Listener */ public void registerDSChangeListener() { DesignTableDataManager.addDsChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { roleTree.refreshTreeNode(); expandTree(roleTree, true); roleTree.updateUI(); } }); } // private class AddAction extends UpdateAction { // public AddAction() { // this.setName(Inter.getLocText("Add")); // this.setSmallIcon(BaseUtils.readIcon("/com/fr/base/images/cell/control/add.png")); // } // // @Override // public void actionPerformed(ActionEvent e) { // refreshDockingView(); // // DefaultTreeModel treeModel = (DefaultTreeModel) roleTree.getModel(); // ExpandMutableTreeNode root = (ExpandMutableTreeNode) treeModel.getRoot(); // ExpandMutableTreeNode parentNode = (ExpandMutableTreeNode) root.getChildAt(0); // String newName = Inter.getLocText("newNode") + (++newIndex); // parentNode.add(new ExpandMutableTreeNode(newName)); // op.addAction(newName); // roleTree.updateUI(); // // try { // synchronized (AuthorityRoleDAOManager.class) { // AuthorityControlFilter pf = AuthorityRoleDAOManager.getAuthControlFilter(true); // // if (AuthorityRoleDAOManager.getAuthorityAllocation(pf, newName) != null) { // newName = Inter.getLocText("newNode") + (++newIndex); // roleTree.refreshTreeNode(); // expandTree(roleTree, true); // } // // AuthorityRoleDAOManager.addAuthorityRole(pf, new Authority(newName), new Allocation(), false, true); // // AuthorityRoleDAOManager.doEnd(pf); // } // } catch (Exception e1) { // FRContext.getLogger().error(e1.getMessage(), e1); // } // } // } // private class RemoveAction extends UpdateAction { // // public RemoveAction() { // this.setName(Inter.getLocText("Remove")); // this.setSmallIcon(UIConstants.CLEAR_ICON); // } // // @Override // public void actionPerformed(ActionEvent e) { // // // NameObject selectedNO = roleTree.getSelectedNameObject(); // // if (selectedNO == null) { // return; // } // // int returnVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("Utils-Are_you_sure_to_remove_the_selected_item") + ":" + selectedNO.getName() + "?", // Inter.getLocText("Remove"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); // if (returnVal == JOptionPane.OK_OPTION) { // op.removeAction(selectedNO.getName()); // // try { // AuthorityControlFilter pf = AuthorityRoleDAOManager.getAuthControlFilter(true); // // AuthorityRoleDAOManager.removeAuthorityRole(pf, new Authority(selectedNO.getName()), true); // AuthorityRoleDAOManager.doEnd(pf); // } catch (Exception e1) { // FRContext.getLogger().error(e1.getMessage(), e1); // } // // roleTree.refreshTreeNode(); // expandTree(roleTree, true); // roleTree.updateUI(); // roleTree.requestFocus(); // roleTree.setSelectionRow(roleTree.getRowCount() - 1); // } // } // } /* * 刷新ReportletsTree */ private class RefreshAction extends UpdateAction { public RefreshAction() { this.setName(Inter.getLocText("FR-Designer_Refresh")); this.setSmallIcon(UIConstants.REFRESH_ICON); } @Override public void actionPerformed(ActionEvent evt) { roleTree.refreshTreeNode(); expandTree(roleTree, true); roleTree.updateUI(); } } // private class RoleTreeCellEditor extends DefaultCellEditor implements TreeCellEditor, CellEditorListener { // // private NameObject editingNO; // private String oldName; // private String newName; // private UITextField jTextField; // // public RoleTreeCellEditor(final UITextField textField) { // super(textField); // this.jTextField = textField; // this.jTextField.setPreferredSize(new Dimension(DesignerEnvManager.getEnvManager().getLastWestRegionContainerWidth() - 5, this.jTextField.getHeight())); // } // // @Override // public Component getTreeCellEditorComponent(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row) { // editingNO = ReportAndFSManagePane.this.roleTree.getSelectedNameObject(); // oldName = editingNO.getName(); // // delegate.setValue(oldName); // // editorComponent.setPreferredSize(new java.awt.Dimension(ReportAndFSManagePane.this.getPreferredSize().width, editorComponent.getPreferredSize().height)); // // return editorComponent; // } // // @Override // // public boolean isCellEditable(EventObject anEvent) { // NameObject no = ReportAndFSManagePane.this.roleTree.getSelectedNameObject(); // return !(no.getName() == Inter.getLocText("Role")); // } // // @Override // public Object getCellEditorValue() { // newName = super.getCellEditorValue().toString(); // editingNO.setName(newName); // return editingNO; // } // // // private boolean checkRoleNameNotEmpty() { // refreshDockingView(); // // String currentText = delegate.getCellEditorValue().toString(); // boolean isContained = false; // AuthorityControlFilter pf = AuthorityRoleDAOManager.getAuthControlFilter(false); // if (pf != null && // !ComparatorUtils.equals(oldName, currentText)) { // try { // Iterator iterator = AuthorityRoleDAOManager.authorityAllocationIterator(pf); // // while (iterator.hasNext()) { // AuthorityAllocation authorityAllocation = (AuthorityAllocation) ((Map.Entry) iterator.next()) // .getValue(); // Authority _authority = authorityAllocation.getAuthority(); // if(ComparatorUtils.equals(_authority.getName(), currentText)){ // isContained = true; // break; // } // } // } catch (Exception e) { // } // } // // if (currentText.isEmpty() || isContained) { // JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("RoleName_Can_Not_Be_Null") + "!"); // roleTree.refreshTreeNode(); // expandTree(roleTree, true); // delegate.setValue(oldName); // return false; // } // return true; // } // // /* // * 下面两个方法是CellEditorListener的 // */ // @Override // public void editingCanceled(ChangeEvent e) { // if (!checkRoleNameNotEmpty()) { // treePath = null; // return; // } // roleTree.stopEditing(); // if (treePath == null) { // return; // } // changeValue(); // roleTree.refreshTreeNode(); // expandTree(roleTree, true); // } // // @Override // public void editingStopped(ChangeEvent e) { // if (!checkRoleNameNotEmpty()) { // treePath = null; // return; // } // changeValue(); // roleTree.refreshTreeNode(); // expandTree(roleTree, true); // roleTree.updateUI(); // } // // private void changeValue() { // newName = delegate.getCellEditorValue().toString(); // if (!newName.isEmpty() && newName != oldName) { // roleTree.setSelectedRoleName(newName); // op.rename(oldName, newName); // // AuthorityControlFilter pf = AuthorityRoleDAOManager.getAuthControlFilter(false); // if (pf != null) { // try { // Iterator iterator = AuthorityRoleDAOManager.authorityAllocationIterator(pf); // // while (iterator.hasNext()) { // AuthorityAllocation authorityAllocation = (AuthorityAllocation) ((Map.Entry) iterator.next()) // .getValue(); // Authority _authority = authorityAllocation.getAuthority(); // if (ComparatorUtils.equals(_authority.getName(), oldName)) { // _authority.setName(newName); // } // } // } catch (Exception e) { // } // } // // try { // AuthorityRoleDAOManager.doEnd(pf); // } catch (Exception e) { // FRContext.getLogger().error(e.getMessage(), e); // } // } // } // } /** * 展开树 * @param tree 树 * @param isExpand 是否展开 */ public void expandTree(JTree tree, boolean isExpand) { TreeNode root = (TreeNode) tree.getModel().getRoot(); expandAll(tree, new TreePath(root), isExpand); } private void expandAll(JTree tree, TreePath parent, boolean expand) { TreeNode node = (TreeNode) parent.getLastPathComponent(); if (node.getChildCount() >= 0) { for (Enumeration e = node.children(); e.hasMoreElements(); ) { TreeNode n = (TreeNode) e.nextElement(); TreePath path = parent.pathByAddingChild(n); expandAll(tree, path, expand); } } if (expand) { tree.expandPath(parent); } else { tree.collapsePath(parent); } } } \ No newline at end of file +package com.fr.design.roleAuthority; + +import com.fr.base.BaseUtils; +import com.fr.base.FRCoreContext; +import com.fr.design.actions.UpdateAction; +import com.fr.design.constants.UIConstants; +import com.fr.design.data.DesignTableDataManager; +import com.fr.design.data.tabledata.Prepare4DataSourceChange; +import com.fr.design.gui.ibutton.UIHeadGroup; +import com.fr.design.gui.icontainer.UIScrollPane; +import com.fr.design.gui.itoolbar.UIToolbar; +import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.DockingView; +import com.fr.design.menu.ToolBarDef; +import com.fr.general.Inter; +import com.fr.general.VT4FR; + +import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import javax.swing.event.TreeSelectionEvent; +import javax.swing.tree.TreeNode; +import javax.swing.tree.TreePath; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.Enumeration; + +/** + * 设计器左下角面板,用于在权限编辑时存放角色 + * Author : daisy + * Date: 13-8-30 + * Time: 下午2:22 + */ +public class ReportAndFSManagePane extends DockingView implements Prepare4DataSourceChange { + + private static final int REPORT_PLATEFORM_MANAGE = 0; + private static final int FS_MANAGE = 1; + private static final int LEFT_GAP = -125; + private static boolean isSupportFS = false; + private TreePath treePath = null; + + private static ReportAndFSManagePane singleton = new ReportAndFSManagePane(); + + private static RoleTree roleTree; + // carl:我先屏了,现在半拉子,等客户要了再好好做 +// private AddAction addAction = new AddAction(); +// private RemoveAction removeAction = new RemoveAction(); + private RefreshAction refreshAction = new RefreshAction(); + private UIHeadGroup buttonGroup; + private RoleSourceOP op; + protected String[] roleNames = new String[2]; + + public synchronized static ReportAndFSManagePane getInstance() { + singleton.op = new RoleSourceOP(); + singleton.op.setDataMode(isSupportFS ? FS_MANAGE : REPORT_PLATEFORM_MANAGE); + singleton.setDefaultSelectedRole(); + return singleton; + + } + + public ReportAndFSManagePane() { + initRoleTree(); + this.setLayout(new BorderLayout(4, 0)); + this.setBorder(null); + this.add(iniToolBarPane(), BorderLayout.NORTH); + refreshAction.setEnabled(true); + UIScrollPane scrollPane = new UIScrollPane(roleTree); + scrollPane.setBorder(BorderFactory.createEmptyBorder(0, 24, 0, 0)); + scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); + scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); + initbuttonGroup(); + JPanel jPanel = new JPanel(new BorderLayout(4, 4)); + JPanel buttonPane = new JPanel(new GridLayout()); + buttonPane.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, UIConstants.LINE_COLOR)); + buttonPane.add(buttonGroup, BorderLayout.CENTER); + jPanel.add(buttonPane, BorderLayout.NORTH); + jPanel.add(scrollPane, BorderLayout.CENTER); + this.add(jPanel, BorderLayout.CENTER); + registerDSChangeListener(); + } + + private void initRoleTree() { + roleTree = new RoleTree() { + public void refreshRoleTree(String selectedRole) { + super.refreshRoleTree(selectedRole); + changeAlreadyEditedPaneRole(selectedRole); + } + + + protected void doWithValueChanged(TreeSelectionEvent e) { + super.doWithValueChanged(e); + TreeNode root = (TreeNode) roleTree.getModel().getRoot(); + TreePath parent = new TreePath(root); + setSelectedRole(roleTree.getSelectedRoleName(), parent); + + } + + protected void setTabRoleName(String roleName) { + roleNames[getMode()] = roleTree.getSelectedRoleName(); + } + }; + roleTree.setEnabled(true); + roleTree.setEditable(false); +// RoleTreeCellEditor treeCellEditor = new RoleTreeCellEditor(new UITextField()); +// treeCellEditor.addCellEditorListener(treeCellEditor); +// roleTree.setCellEditor(treeCellEditor); + roleTree.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + super.mouseClicked(e); + roleTree.setEditable(false); +// int row = roleTree.getRowForLocation(e.getX(), e.getY()); +// TreePath path = roleTree.getPathForLocation(e.getX(), e.getY()); +// if (e.getClickCount() == 2 && buttonGroup.getSelectedIndex() == REPORT_PLATEFORM_MANAGE) { +// PrivilegeManagerProvider pm = PrivilegeManager.getProviderInstance(); +// AuthenticationProvider ap = pm.getAuthenticationProvider(); +// if (!(ap instanceof DaoAuthenticationProvider)) { +// roleTree.setEditable(true); +// roleTree.startEditingAtPath(path); +// treePath = path; +// } +// } + } + }); + } + + private void changeAlreadyEditedPaneRole(String selectedRole) { + RolesAlreadyEditedPane.getInstance().refreshDockingView(); + RoleTree roleTree = RolesAlreadyEditedPane.getInstance().getRoleTree(); + TreeNode root = (TreeNode) roleTree.getModel().getRoot(); + TreePath parent = new TreePath(root); + roleTree.setSelectedRole(selectedRole, parent); + } + + public void setDefaultSelectedRole() { + //设置选中的节点 + TreeNode root = (TreeNode) roleTree.getModel().getRoot(); + TreePath parent = new TreePath(root); + ExpandMutableTreeNode node = (ExpandMutableTreeNode) parent.getLastPathComponent(); + String selectedRole = null; + if (singleton != null) { + selectedRole = roleNames[getMode()]; + } + if (selectedRole == null) { + if (node.getChildCount() <= 0 || node.getFirstChild().getChildCount() <= 0) { + return; + } + selectedRole = node.getFirstChild().getChildAt(0).toString(); + } + roleTree.setSelectedRole(selectedRole, parent); + } + + + public RoleTree getRoleTree() { + return roleTree; + } + + /** + * 检查f) 每增删改一个角色信息(及时保存),先对比下privilege下之前的角色信息有没有发生变化(即在此期间有没有在其他途径中修改过) + */ + private void checkChanges() { + //如若有变化,则弹出下面的对话框 + int returnVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("FR-Designer_Role_changed_isRefresh") + "?", + Inter.getLocText("FR-Designer_Refresh"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE); + if (returnVal == JOptionPane.OK_OPTION) { + roleTree.refreshTreeNode(); + expandTree(roleTree, true); + roleTree.updateUI(); + } + + } + + private JPanel iniToolBarPane() { + ToolBarDef toolbarDef = new ToolBarDef(); + toolbarDef.addShortCut(refreshAction); + UIToolbar toolBar = ToolBarDef.createJToolBar(); + toolbarDef.updateToolBar(toolBar); + JPanel toolbarPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); + toolbarPane.add(toolBar, BorderLayout.CENTER); + return toolbarPane; + } + + private void initbuttonGroup() { + Icon[] iconArray = new Icon[]{BaseUtils.readIcon("/com/fr/web/images/platform/demo.png")}; + String[] textArray = new String[]{Inter.getLocText("FR-Designer_FS_Name")}; + buttonGroup = new UIHeadGroup(iconArray, textArray) { + public void tabChanged(int index) { + roleTree.setEditable(false); + if (op != null) { + op.setDataMode(getMode()); + //判断是否可编辑 + refreshDockingView(); + } + setDefaultSelectedRole(); + if (singleton != null) { + changeAlreadyEditedPaneRole(roleNames[getMode()]); + } + } + }; + buttonGroup.setBorder(BorderFactory.createMatteBorder(1, LEFT_GAP, 0, 0, UIConstants.LINE_COLOR)); + buttonGroup.setNeedLeftRightOutLine(false); + } + + private int getMode(){ + return isSupportFS?FS_MANAGE: REPORT_PLATEFORM_MANAGE; + } + + +// /** +// * 检查看看是否可以增删刷新按钮是都可以编辑,并且检查角色树是不是可以编辑 +// */ +// public void checkToolButtonsEnabled() { +// if (buttonGroup.getSelectedIndex() == REPORT_PLATEFORM_MANAGE) { +// PrivilegeManagerProvider pm = PrivilegeManager.getProviderInstance(); +// AuthenticationProvider ap = pm.getAuthenticationProvider(); +// PrivilegeFilter pf = pm.getPrivilegeFilter(); +// boolean isClickable = !(ap instanceof DaoAuthenticationProvider) +// && pf instanceof AuthorityControlFilter; +// addAction.setEnabled(isClickable); +// removeAction.setEnabled(isClickable); +// } else { +// addAction.setEnabled(false); +// removeAction.setEnabled(false); +// } +// +// } + + + /** + * 刷新界面 + */ + public void refreshDockingView() { + populate(new RoleSourceOP()); +// this.checkToolButtonsEnabled(); + } + + private void populate(RoleSourceOP op) { + this.op = op; + roleTree.populate(op); + expandTree(roleTree, true); + } + + public String getViewTitle() { + return null; + } + + public Icon getViewIcon() { + return null; + } + + /** + * 最佳定位 + * @return 定位 + */ + public Location preferredLocation() { + return null; + } + + /** + * 注册数据库改变的响应的Listener + */ + public void registerDSChangeListener() { + DesignTableDataManager.addDsChangeListener(new ChangeListener() { + + public void stateChanged(ChangeEvent e) { + roleTree.refreshTreeNode(); + expandTree(roleTree, true); + roleTree.updateUI(); + } + }); + + } + +// private class AddAction extends UpdateAction { +// public AddAction() { +// this.setName(Inter.getLocText("Add")); +// this.setSmallIcon(BaseUtils.readIcon("/com/fr/base/images/cell/control/add.png")); +// } +// +// @Override +// public void actionPerformed(ActionEvent e) { +// refreshDockingView(); +// +// DefaultTreeModel treeModel = (DefaultTreeModel) roleTree.getModel(); +// ExpandMutableTreeNode root = (ExpandMutableTreeNode) treeModel.getRoot(); +// ExpandMutableTreeNode parentNode = (ExpandMutableTreeNode) root.getChildAt(0); +// String newName = Inter.getLocText("newNode") + (++newIndex); +// parentNode.add(new ExpandMutableTreeNode(newName)); +// op.addAction(newName); +// roleTree.updateUI(); +// +// try { +// synchronized (AuthorityRoleDAOManager.class) { +// AuthorityControlFilter pf = AuthorityRoleDAOManager.getAuthControlFilter(true); +// +// if (AuthorityRoleDAOManager.getAuthorityAllocation(pf, newName) != null) { +// newName = Inter.getLocText("newNode") + (++newIndex); +// roleTree.refreshTreeNode(); +// expandTree(roleTree, true); +// } +// +// AuthorityRoleDAOManager.addAuthorityRole(pf, new Authority(newName), new Allocation(), false, true); +// +// AuthorityRoleDAOManager.doEnd(pf); +// } +// } catch (Exception e1) { +// FRContext.getLogger().error(e1.getMessage(), e1); +// } +// } +// } + +// private class RemoveAction extends UpdateAction { +// +// public RemoveAction() { +// this.setName(Inter.getLocText("Remove")); +// this.setSmallIcon(UIConstants.CLEAR_ICON); +// } +// +// @Override +// public void actionPerformed(ActionEvent e) { +// +// +// NameObject selectedNO = roleTree.getSelectedNameObject(); +// +// if (selectedNO == null) { +// return; +// } +// +// int returnVal = JOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("Utils-Are_you_sure_to_remove_the_selected_item") + ":" + selectedNO.getName() + "?", +// Inter.getLocText("Remove"), JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); +// if (returnVal == JOptionPane.OK_OPTION) { +// op.removeAction(selectedNO.getName()); +// +// try { +// AuthorityControlFilter pf = AuthorityRoleDAOManager.getAuthControlFilter(true); +// +// AuthorityRoleDAOManager.removeAuthorityRole(pf, new Authority(selectedNO.getName()), true); +// AuthorityRoleDAOManager.doEnd(pf); +// } catch (Exception e1) { +// FRContext.getLogger().error(e1.getMessage(), e1); +// } +// +// roleTree.refreshTreeNode(); +// expandTree(roleTree, true); +// roleTree.updateUI(); +// roleTree.requestFocus(); +// roleTree.setSelectionRow(roleTree.getRowCount() - 1); +// } +// } +// } + + + /* + * 刷新ReportletsTree + */ + private class RefreshAction extends UpdateAction { + + public RefreshAction() { + this.setName(Inter.getLocText("FR-Designer_Refresh")); + this.setSmallIcon(UIConstants.REFRESH_ICON); + } + + @Override + public void actionPerformed(ActionEvent evt) { + roleTree.refreshTreeNode(); + expandTree(roleTree, true); + roleTree.updateUI(); + } + } + + +// private class RoleTreeCellEditor extends DefaultCellEditor implements TreeCellEditor, CellEditorListener { +// +// private NameObject editingNO; +// private String oldName; +// private String newName; +// private UITextField jTextField; +// +// public RoleTreeCellEditor(final UITextField textField) { +// super(textField); +// this.jTextField = textField; +// this.jTextField.setPreferredSize(new Dimension(DesignerEnvManager.getEnvManager().getLastWestRegionContainerWidth() - 5, this.jTextField.getHeight())); +// } +// +// @Override +// public Component getTreeCellEditorComponent(JTree tree, Object value, boolean isSelected, boolean expanded, boolean leaf, int row) { +// editingNO = ReportAndFSManagePane.this.roleTree.getSelectedNameObject(); +// oldName = editingNO.getName(); +// +// delegate.setValue(oldName); +// +// editorComponent.setPreferredSize(new java.awt.Dimension(ReportAndFSManagePane.this.getPreferredSize().width, editorComponent.getPreferredSize().height)); +// +// return editorComponent; +// } +// +// @Override +// +// public boolean isCellEditable(EventObject anEvent) { +// NameObject no = ReportAndFSManagePane.this.roleTree.getSelectedNameObject(); +// return !(no.getName() == Inter.getLocText("Role")); +// } +// +// @Override +// public Object getCellEditorValue() { +// newName = super.getCellEditorValue().toString(); +// editingNO.setName(newName); +// return editingNO; +// } +// +// +// private boolean checkRoleNameNotEmpty() { +// refreshDockingView(); +// +// String currentText = delegate.getCellEditorValue().toString(); +// boolean isContained = false; +// AuthorityControlFilter pf = AuthorityRoleDAOManager.getAuthControlFilter(false); +// if (pf != null && +// !ComparatorUtils.equals(oldName, currentText)) { +// try { +// Iterator iterator = AuthorityRoleDAOManager.authorityAllocationIterator(pf); +// +// while (iterator.hasNext()) { +// AuthorityAllocation authorityAllocation = (AuthorityAllocation) ((Map.Entry) iterator.next()) +// .getValue(); +// Authority _authority = authorityAllocation.getAuthority(); +// if(ComparatorUtils.equals(_authority.getName(), currentText)){ +// isContained = true; +// break; +// } +// } +// } catch (Exception e) { +// } +// } +// +// if (currentText.isEmpty() || isContained) { +// JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Inter.getLocText("RoleName_Can_Not_Be_Null") + "!"); +// roleTree.refreshTreeNode(); +// expandTree(roleTree, true); +// delegate.setValue(oldName); +// return false; +// } +// return true; +// } +// +// /* +// * 下面两个方法是CellEditorListener的 +// */ +// @Override +// public void editingCanceled(ChangeEvent e) { +// if (!checkRoleNameNotEmpty()) { +// treePath = null; +// return; +// } +// roleTree.stopEditing(); +// if (treePath == null) { +// return; +// } +// changeValue(); +// roleTree.refreshTreeNode(); +// expandTree(roleTree, true); +// } +// +// @Override +// public void editingStopped(ChangeEvent e) { +// if (!checkRoleNameNotEmpty()) { +// treePath = null; +// return; +// } +// changeValue(); +// roleTree.refreshTreeNode(); +// expandTree(roleTree, true); +// roleTree.updateUI(); +// } +// +// private void changeValue() { +// newName = delegate.getCellEditorValue().toString(); +// if (!newName.isEmpty() && newName != oldName) { +// roleTree.setSelectedRoleName(newName); +// op.rename(oldName, newName); +// +// AuthorityControlFilter pf = AuthorityRoleDAOManager.getAuthControlFilter(false); +// if (pf != null) { +// try { +// Iterator iterator = AuthorityRoleDAOManager.authorityAllocationIterator(pf); +// +// while (iterator.hasNext()) { +// AuthorityAllocation authorityAllocation = (AuthorityAllocation) ((Map.Entry) iterator.next()) +// .getValue(); +// Authority _authority = authorityAllocation.getAuthority(); +// if (ComparatorUtils.equals(_authority.getName(), oldName)) { +// _authority.setName(newName); +// } +// } +// } catch (Exception e) { +// } +// } +// +// try { +// AuthorityRoleDAOManager.doEnd(pf); +// } catch (Exception e) { +// FRContext.getLogger().error(e.getMessage(), e); +// } +// } +// } +// } + + + /** + * 展开树 + * @param tree 树 + * @param isExpand 是否展开 + */ + public void expandTree(JTree tree, boolean isExpand) { + TreeNode root = (TreeNode) tree.getModel().getRoot(); + expandAll(tree, new TreePath(root), isExpand); + } + + + private void expandAll(JTree tree, TreePath parent, boolean expand) { + TreeNode node = (TreeNode) parent.getLastPathComponent(); + if (node.getChildCount() >= 0) { + for (Enumeration e = node.children(); e.hasMoreElements(); ) { + TreeNode n = (TreeNode) e.nextElement(); + TreePath path = parent.pathByAddingChild(n); + expandAll(tree, path, expand); + } + } + if (expand) { + tree.expandPath(parent); + } else { + tree.collapsePath(parent); + } + } + +} \ No newline at end of file