From 6213784e43bab3455bfd1e11e7c0a5379bca4267 Mon Sep 17 00:00:00 2001 From: eason-skx Date: Thu, 15 Jun 2017 15:08:54 +0800 Subject: [PATCH 01/50] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=A0=87=E7=AD=BE?= =?UTF-8?q?=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SeriesCondition/dlp/DataLabelPane.java | 27 +------------------ 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/designer_chart/src/com/fr/design/chart/series/SeriesCondition/dlp/DataLabelPane.java b/designer_chart/src/com/fr/design/chart/series/SeriesCondition/dlp/DataLabelPane.java index 7d8b6c8ce..3bad0eefd 100644 --- a/designer_chart/src/com/fr/design/chart/series/SeriesCondition/dlp/DataLabelPane.java +++ b/designer_chart/src/com/fr/design/chart/series/SeriesCondition/dlp/DataLabelPane.java @@ -111,34 +111,9 @@ public class DataLabelPane extends TooltipContentsPane { } protected JPanel createJPanel4Position() { - // 标签位置:上下左右中. - bottomButton = new UIRadioButton(Inter.getLocText("StyleAlignment-Bottom")); - leftButton = new UIRadioButton(Inter.getLocText("StyleAlignment-Left")); - rigtButton = new UIRadioButton(Inter.getLocText("StyleAlignment-Right")); - topButton = new UIRadioButton(Inter.getLocText("StyleAlignment-Top")); - centerButton = new UIRadioButton(Inter.getLocText("Center")); - - ButtonGroup bg = new ButtonGroup(); - bg.add(bottomButton); - bg.add(leftButton); - bg.add(rigtButton); - bg.add(topButton); - bg.add(centerButton); - topButton.setSelected(true); - - JPanel buttonPane = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane(); - buttonPane.add(new UILabel(Inter.getLocText(new String[]{"Label", "Layout"}) + ":")); - buttonPane.add(bottomButton); - buttonPane.add(leftButton); - buttonPane.add(rigtButton); - buttonPane.add(topButton); - buttonPane.add(centerButton); - - return buttonPane; + return null; } - - public void populate(AttrContents seriesAttrContents) { super.populate(seriesAttrContents); String dataLabel = seriesAttrContents.getSeriesLabel(); From de3fbb5cabd0ca2ca9b076b9c06b91e1bc46ad9e Mon Sep 17 00:00:00 2001 From: eason-skx Date: Thu, 15 Jun 2017 15:27:32 +0800 Subject: [PATCH 02/50] pmd --- .../design/chart/series/SeriesCondition/dlp/DataLabelPane.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer_chart/src/com/fr/design/chart/series/SeriesCondition/dlp/DataLabelPane.java b/designer_chart/src/com/fr/design/chart/series/SeriesCondition/dlp/DataLabelPane.java index 3bad0eefd..3a200ee3c 100644 --- a/designer_chart/src/com/fr/design/chart/series/SeriesCondition/dlp/DataLabelPane.java +++ b/designer_chart/src/com/fr/design/chart/series/SeriesCondition/dlp/DataLabelPane.java @@ -96,7 +96,7 @@ public class DataLabelPane extends TooltipContentsPane { } delimiterBox.setPreferredSize(new Dimension(70, 20)); JPanel boxPane = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(); - boxPane.add(new UILabel(Inter.getLocText("Form-Delimiter") + ":")); + boxPane.add(new UILabel(Inter.getLocText("FR-Designer_Dismenber") + ":")); boxPane.add(delimiterBox); return boxPane; } From 5a490cf8dd753d983b46edc2d1b8fc8c96e2bd13 Mon Sep 17 00:00:00 2001 From: mengao <283296419@qq.com> Date: Mon, 19 Jun 2017 13:53:39 +0800 Subject: [PATCH 03/50] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug=EF=BC=9A=E6=9D=A1?= =?UTF-8?q?=E4=BB=B6=E6=98=BE=E7=A4=BA=E9=87=8C=E8=AE=BE=E7=BD=AE=E6=9D=A1?= =?UTF-8?q?=E4=BB=B6=E5=86=85=E5=AE=B9=E4=B8=BA=E6=95=B0=E6=8D=AE=E5=88=97?= =?UTF-8?q?=EF=BC=8C=E6=8A=8A=E5=AF=B9=E5=BA=94=E7=9A=84=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E9=9B=86=E5=88=A0=E6=8E=89=E5=90=8E=EF=BC=8C=E7=82=B9=E5=87=BB?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E7=9A=84=E6=9D=A1=E4=BB=B6=E5=B1=9E=E6=80=A7?= =?UTF-8?q?=EF=BC=8C=E9=A1=B5=E9=9D=A2=E6=89=93=E4=B8=8D=E5=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../editor/editor/ColumnSelectedEditor.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/designer_base/src/com/fr/design/editor/editor/ColumnSelectedEditor.java b/designer_base/src/com/fr/design/editor/editor/ColumnSelectedEditor.java index 0f1c50a5f..29b1a3ea0 100644 --- a/designer_base/src/com/fr/design/editor/editor/ColumnSelectedEditor.java +++ b/designer_base/src/com/fr/design/editor/editor/ColumnSelectedEditor.java @@ -36,15 +36,18 @@ public class ColumnSelectedEditor extends Editor { @Override public void itemStateChanged(ItemEvent e) { - //这边需要重新初始化columnNames, 否则nameList长度和columnNames长度不同导致出錯。 - List nameList = tableDataComboBox.getSelectedItem().calculateColumnNameList(); - columnNames = new String[nameList.size()]; - columnNames = tableDataComboBox.getSelectedItem().calculateColumnNameList().toArray(columnNames); - columnNameComboBox.removeAllItems(); - for (int i = 0; i < columnNames.length; i++) { - columnNameComboBox.addItem(columnNames[i]); + TableDataWrapper tableDataWrapper = tableDataComboBox.getSelectedItem(); + if (tableDataWrapper != null) { + //这边需要重新初始化columnNames, 否则nameList长度和columnNames长度不同导致出錯。 + List nameList = tableDataComboBox.getSelectedItem().calculateColumnNameList(); + columnNames = new String[nameList.size()]; + columnNames = tableDataComboBox.getSelectedItem().calculateColumnNameList().toArray(columnNames); + columnNameComboBox.removeAllItems(); + for (int i = 0; i < columnNames.length; i++) { + columnNameComboBox.addItem(columnNames[i]); + } + columnNameComboBox.validate(); } - columnNameComboBox.validate(); } }); columnNameComboBox = new UIComboBox(); From c5536e6d61d93a766380a4e8221d601276e297ee Mon Sep 17 00:00:00 2001 From: mengao <283296419@qq.com> Date: Tue, 20 Jun 2017 17:20:39 +0800 Subject: [PATCH 04/50] =?UTF-8?q?=E4=BF=AE=E6=94=B9pmd=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../editor/editor/ColumnSelectedEditor.java | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/designer_base/src/com/fr/design/editor/editor/ColumnSelectedEditor.java b/designer_base/src/com/fr/design/editor/editor/ColumnSelectedEditor.java index 29b1a3ea0..e21099d71 100644 --- a/designer_base/src/com/fr/design/editor/editor/ColumnSelectedEditor.java +++ b/designer_base/src/com/fr/design/editor/editor/ColumnSelectedEditor.java @@ -37,17 +37,18 @@ public class ColumnSelectedEditor extends Editor { @Override public void itemStateChanged(ItemEvent e) { TableDataWrapper tableDataWrapper = tableDataComboBox.getSelectedItem(); - if (tableDataWrapper != null) { - //这边需要重新初始化columnNames, 否则nameList长度和columnNames长度不同导致出錯。 - List nameList = tableDataComboBox.getSelectedItem().calculateColumnNameList(); - columnNames = new String[nameList.size()]; - columnNames = tableDataComboBox.getSelectedItem().calculateColumnNameList().toArray(columnNames); - columnNameComboBox.removeAllItems(); - for (int i = 0; i < columnNames.length; i++) { - columnNameComboBox.addItem(columnNames[i]); - } - columnNameComboBox.validate(); + if (tableDataWrapper == null) { + return; } + //这边需要重新初始化columnNames, 否则nameList长度和columnNames长度不同导致出錯。 + List nameList = tableDataComboBox.getSelectedItem().calculateColumnNameList(); + columnNames = new String[nameList.size()]; + columnNames = tableDataComboBox.getSelectedItem().calculateColumnNameList().toArray(columnNames); + columnNameComboBox.removeAllItems(); + for (int i = 0; i < columnNames.length; i++) { + columnNameComboBox.addItem(columnNames[i]); + } + columnNameComboBox.validate(); } }); columnNameComboBox = new UIComboBox(); From 382268234df6ed7c8ad3b1172bdf66c8a2ac6b31 Mon Sep 17 00:00:00 2001 From: mengao <283296419@qq.com> Date: Tue, 20 Jun 2017 17:25:45 +0800 Subject: [PATCH 05/50] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dpmd=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/editor/editor/ColumnSelectedEditor.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/designer_base/src/com/fr/design/editor/editor/ColumnSelectedEditor.java b/designer_base/src/com/fr/design/editor/editor/ColumnSelectedEditor.java index e21099d71..22516882b 100644 --- a/designer_base/src/com/fr/design/editor/editor/ColumnSelectedEditor.java +++ b/designer_base/src/com/fr/design/editor/editor/ColumnSelectedEditor.java @@ -36,13 +36,13 @@ public class ColumnSelectedEditor extends Editor { @Override public void itemStateChanged(ItemEvent e) { - TableDataWrapper tableDataWrapper = tableDataComboBox.getSelectedItem(); - if (tableDataWrapper == null) { - return; - } - //这边需要重新初始化columnNames, 否则nameList长度和columnNames长度不同导致出錯。 - List nameList = tableDataComboBox.getSelectedItem().calculateColumnNameList(); - columnNames = new String[nameList.size()]; + TableDataWrapper tableDataWrapper = tableDataComboBox.getSelectedItem(); + if (tableDataWrapper == null) { + return; + } + //这边需要重新初始化columnNames, 否则nameList长度和columnNames长度不同导致出錯。 + List nameList = tableDataWrapper.calculateColumnNameList(); + columnNames = new String[nameList.size()]; columnNames = tableDataComboBox.getSelectedItem().calculateColumnNameList().toArray(columnNames); columnNameComboBox.removeAllItems(); for (int i = 0; i < columnNames.length; i++) { From 58bc5e247e1f26c0288d5e65af6af5cb3e6b4ac0 Mon Sep 17 00:00:00 2001 From: mengao <283296419@qq.com> Date: Tue, 20 Jun 2017 17:57:47 +0800 Subject: [PATCH 06/50] =?UTF-8?q?=E4=BF=AE=E6=94=B9pmd=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/editor/editor/ColumnSelectedEditor.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/designer_base/src/com/fr/design/editor/editor/ColumnSelectedEditor.java b/designer_base/src/com/fr/design/editor/editor/ColumnSelectedEditor.java index 22516882b..71014d4c8 100644 --- a/designer_base/src/com/fr/design/editor/editor/ColumnSelectedEditor.java +++ b/designer_base/src/com/fr/design/editor/editor/ColumnSelectedEditor.java @@ -68,7 +68,7 @@ public class ColumnSelectedEditor extends Editor { dsColumn.setDsName(tableDataWrappe.getTableDataName()); TableDataColumn column; String columnExp = (String) this.columnNameComboBox.getSelectedItem(); - if (StringUtils.isNotBlank(columnExp) && (columnExp.length() > 0 && columnExp.charAt(0) == '#') && !columnExp.endsWith("#")) { + if (StringUtils.isNotBlank(columnExp) && checkColumnExp(columnExp)) { String number = columnExp.substring(1); Pattern pattern = Pattern.compile("[^\\d]"); if (pattern.matcher(number).find()) { @@ -84,6 +84,10 @@ public class ColumnSelectedEditor extends Editor { return dsColumn; } + private boolean checkColumnExp (String columnExp) { + return (columnExp.length() > 0 && columnExp.charAt(0) == '#') && !columnExp.endsWith("#"); + } + public String getIconName() { return "ds_column"; } From eb63b92671655b467a2a0c2b93913cf181d22175 Mon Sep 17 00:00:00 2001 From: neil Date: Fri, 30 Jun 2017 17:11:00 +0800 Subject: [PATCH 07/50] =?UTF-8?q?REPORT-2825=20=E8=AE=AD=E7=BB=83=E6=8F=92?= =?UTF-8?q?=E4=BB=B6button=E5=87=BA=E7=8E=B0=E4=BA=86=E5=A4=9A=E4=B8=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/templateinfo/JWorkBookProcessInfo.java | 8 +++++++- .../fun/impl/AbstractDsinFrameUpButtonProvider.java | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/designer/src/com/fr/design/mainframe/templateinfo/JWorkBookProcessInfo.java b/designer/src/com/fr/design/mainframe/templateinfo/JWorkBookProcessInfo.java index bf5d835d2..306c6b0d1 100644 --- a/designer/src/com/fr/design/mainframe/templateinfo/JWorkBookProcessInfo.java +++ b/designer/src/com/fr/design/mainframe/templateinfo/JWorkBookProcessInfo.java @@ -2,6 +2,7 @@ package com.fr.design.mainframe.templateinfo; import com.fr.base.parameter.ParameterUI; import com.fr.main.impl.WorkBook; +import com.fr.main.parameter.ReportParameterAttr; import com.fr.report.cellcase.CellCase; import com.fr.report.poly.PolyWorkSheet; import com.fr.report.worksheet.WorkSheet; @@ -68,7 +69,12 @@ public class JWorkBookProcessInfo extends TemplateProcessInfo { } // 获取模板控件数 public int getWidgetCount() { - ParameterUI pui = template.getReportParameterAttr().getParameterUI(); + ReportParameterAttr attr = template.getReportParameterAttr(); + if (attr == null) { + return 0; + } + + ParameterUI pui = attr.getParameterUI(); return pui == null ? 0 : (pui.getAllWidgets().length - 1); } } diff --git a/designer_base/src/com/fr/design/fun/impl/AbstractDsinFrameUpButtonProvider.java b/designer_base/src/com/fr/design/fun/impl/AbstractDsinFrameUpButtonProvider.java index bd1f70829..03e76dcdf 100644 --- a/designer_base/src/com/fr/design/fun/impl/AbstractDsinFrameUpButtonProvider.java +++ b/designer_base/src/com/fr/design/fun/impl/AbstractDsinFrameUpButtonProvider.java @@ -2,6 +2,7 @@ package com.fr.design.fun.impl; import com.fr.design.fun.DesignerFrameUpButtonProvider; import com.fr.design.gui.ibutton.UIButton; +import com.fr.stable.fun.impl.AbstractProvider; import com.fr.stable.fun.mark.API; /** @@ -10,7 +11,7 @@ import com.fr.stable.fun.mark.API; * Time: 15:50 */ @API(level = DesignerFrameUpButtonProvider.CURRENT_LEVEL) -public abstract class AbstractDsinFrameUpButtonProvider implements DesignerFrameUpButtonProvider { +public abstract class AbstractDsinFrameUpButtonProvider extends AbstractProvider implements DesignerFrameUpButtonProvider { @Override public UIButton[] getUpButtons(int menuState) { return new UIButton[0]; From 58a009ed1092c119f0c288da3da4898d0ef05e6c Mon Sep 17 00:00:00 2001 From: sunmondong <646575997@qq.com> Date: Thu, 6 Jul 2017 15:49:36 +0800 Subject: [PATCH 08/50] fix --- build.performance.gradle | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.performance.gradle b/build.performance.gradle index 132db468f..102205679 100644 --- a/build.performance.gradle +++ b/build.performance.gradle @@ -14,7 +14,8 @@ task appletJar<<{ 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}/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 b7ca742217b97eaef5e27a24072405792b5c3c53 Mon Sep 17 00:00:00 2001 From: mengao <283296419@qq.com> Date: Mon, 10 Jul 2017 14:44:10 +0800 Subject: [PATCH 09/50] =?UTF-8?q?=E5=A4=9A=E5=88=86=E7=B1=BB=E8=BD=B4?= =?UTF-8?q?=E6=95=B4=E4=BD=93=E4=BB=A3=E7=A0=81=EF=BC=8C=E7=AC=AC=E4=B8=80?= =?UTF-8?q?=E6=AC=A1=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...goryPlotMoreCateReportDataContentPane.java | 38 ++++++++++----- ...egoryPlotMoreCateTableDataContentPane.java | 47 ++++++++++++------- 2 files changed, 57 insertions(+), 28 deletions(-) diff --git a/designer_chart/src/com/fr/design/mainframe/chart/gui/data/report/CategoryPlotMoreCateReportDataContentPane.java b/designer_chart/src/com/fr/design/mainframe/chart/gui/data/report/CategoryPlotMoreCateReportDataContentPane.java index 07d699dae..1cd4b8c09 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/gui/data/report/CategoryPlotMoreCateReportDataContentPane.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/gui/data/report/CategoryPlotMoreCateReportDataContentPane.java @@ -3,6 +3,7 @@ package com.fr.design.mainframe.chart.gui.data.report; import com.fr.base.BaseUtils; import com.fr.base.Utils; import com.fr.base.chart.chartdata.TopDefinitionProvider; +import com.fr.chart.chartattr.Axis; import com.fr.chart.chartattr.Bar2DPlot; import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.chartdata.NormalReportDataDefinition; @@ -37,6 +38,10 @@ public class CategoryPlotMoreCateReportDataContentPane extends CategoryPlotRepor private ArrayList formualList = new ArrayList(); private UIObserverListener uiobListener = null; + public ArrayList getFormualList() { + return formualList; + } + public CategoryPlotMoreCateReportDataContentPane() { } @@ -105,13 +110,13 @@ public class CategoryPlotMoreCateReportDataContentPane extends CategoryPlotRepor public void actionPerformed(ActionEvent e) { boxPane.remove(newButtonPane); formualList.remove(pane); - checkAddButton(); + checkComponent(); relayoutPane(); } }); delButton.registerChangeListener(uiobListener); - - checkAddButton(); + + checkComponent(); relayoutPane(); return pane; @@ -121,7 +126,11 @@ public class CategoryPlotMoreCateReportDataContentPane extends CategoryPlotRepor int size = formualList.size(); addButton.setEnabled(size < 2); } - + + protected void checkComponent() { + checkAddButton(); + } + private void relayoutPane() { this.revalidate(); } @@ -163,20 +172,25 @@ public class CategoryPlotMoreCateReportDataContentPane extends CategoryPlotRepor checkAddButton(); } - + public void updateBean(ChartCollection collection) { super.updateBean(collection); - + TopDefinitionProvider definition = collection.getSelectedChart().getFilterDefinition(); + Axis axis = collection.getSelectedChart().getPlot().getxAxis(); if (definition instanceof NormalReportDataDefinition) { NormalReportDataDefinition reportDefinition = (NormalReportDataDefinition) definition; - + reportDefinition.clearMoreCate(); - - for(int i = 0, size = formualList.size(); i < size; i++) { - TinyFormulaPane pane = formualList.get(i); - reportDefinition.addMoreCate(canBeFormula(pane.updateBean())); - } + updateMoreCate(reportDefinition, axis); + + } + } + + protected void updateMoreCate(NormalReportDataDefinition reportDefinition, Axis axis) { + for (int i = 0, size = formualList.size(); i < size; i++) { + TinyFormulaPane pane = formualList.get(i); + reportDefinition.addMoreCate(canBeFormula(pane.updateBean())); } } } \ No newline at end of file diff --git a/designer_chart/src/com/fr/design/mainframe/chart/gui/data/table/CategoryPlotMoreCateTableDataContentPane.java b/designer_chart/src/com/fr/design/mainframe/chart/gui/data/table/CategoryPlotMoreCateTableDataContentPane.java index 9ae7696d9..f37fc9356 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/gui/data/table/CategoryPlotMoreCateTableDataContentPane.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/gui/data/table/CategoryPlotMoreCateTableDataContentPane.java @@ -4,6 +4,7 @@ import com.fr.base.BaseUtils; import com.fr.base.chart.chartdata.TopDefinitionProvider; import com.fr.chart.chartattr.Bar2DPlot; import com.fr.chart.chartattr.ChartCollection; +import com.fr.chart.chartattr.Plot; import com.fr.chart.chartdata.NormalTableDataDefinition; import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserverListener; @@ -41,7 +42,11 @@ public class CategoryPlotMoreCateTableDataContentPane extends CategoryPlotTableD private UIButton addButton; private UIObserverListener uiobListener = null; - + + public ArrayList getBoxList() { + return boxList; + } + public CategoryPlotMoreCateTableDataContentPane() { // do nothing } @@ -86,8 +91,8 @@ public class CategoryPlotMoreCateTableDataContentPane extends CategoryPlotTableD public void itemStateChanged(ItemEvent e) { checkSeriseUse(categoryCombox.getSelectedItem() != null); makeToolTipUse(categoryCombox); - - checkAddButton(); + + checkComponent(); } }); } @@ -126,15 +131,15 @@ public class CategoryPlotMoreCateTableDataContentPane extends CategoryPlotTableD buttonPane.add(delButton); boxPane.add(buttonPane); boxList.add(combox); - - checkAddButton(); + + checkComponent(); delButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { boxPane.remove(buttonPane); boxList.remove(combox); - checkAddButton(); + checkComponent(); relayoutPane(); } }); @@ -147,6 +152,10 @@ public class CategoryPlotMoreCateTableDataContentPane extends CategoryPlotTableD int size = boxList.size(); addButton.setEnabled(size < 2 && categoryCombox.getSelectedItem() != null); } + + protected void checkComponent() { + checkAddButton(); + } private void relayoutPane() { this.revalidate(); @@ -159,8 +168,8 @@ public class CategoryPlotMoreCateTableDataContentPane extends CategoryPlotTableD */ public void checkBoxUse(boolean hasUse) { super.checkBoxUse(hasUse); - - checkAddButton(); + + checkComponent(); } protected void refreshBoxListWithSelectTableData(List list) { @@ -218,17 +227,23 @@ public class CategoryPlotMoreCateTableDataContentPane extends CategoryPlotTableD */ public void updateBean(ChartCollection collection) { super.updateBean(collection); - + TopDefinitionProvider top = collection.getSelectedChart().getFilterDefinition(); - if(top instanceof NormalTableDataDefinition) { - NormalTableDataDefinition normal = (NormalTableDataDefinition)top; + Plot plot = collection.getSelectedChart().getPlot(); + if (top instanceof NormalTableDataDefinition) { + NormalTableDataDefinition normal = (NormalTableDataDefinition) top; normal.clearMoreCate(); - for(int i = 0, size = boxList.size(); i < size; i++) { - UIComboBox box = boxList.get(i); - if(box.getSelectedItem() != null) { - normal.addMoreCate(box.getSelectedItem().toString()); - } + updateMoreCate(normal, plot); + } + } + + protected void updateMoreCate(NormalTableDataDefinition normal, Plot plot) { + for (int i = 0, size = boxList.size(); i < size; i++) { + UIComboBox box = boxList.get(i); + if (box.getSelectedItem() != null) { + normal.addMoreCate(box.getSelectedItem().toString()); } } } + } \ No newline at end of file From 2aa4fee16e180840b8567400f6d323e8726900e7 Mon Sep 17 00:00:00 2001 From: mengao <283296419@qq.com> Date: Tue, 11 Jul 2017 09:31:06 +0800 Subject: [PATCH 10/50] =?UTF-8?q?=E5=B0=86Table=E4=B8=AD=E7=9A=84=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E7=B1=BB=E5=9E=8BArrayList=E6=94=B9?= =?UTF-8?q?=E4=B8=BAList=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/table/CategoryPlotMoreCateTableDataContentPane.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer_chart/src/com/fr/design/mainframe/chart/gui/data/table/CategoryPlotMoreCateTableDataContentPane.java b/designer_chart/src/com/fr/design/mainframe/chart/gui/data/table/CategoryPlotMoreCateTableDataContentPane.java index f37fc9356..aae7e3540 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/gui/data/table/CategoryPlotMoreCateTableDataContentPane.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/gui/data/table/CategoryPlotMoreCateTableDataContentPane.java @@ -43,7 +43,7 @@ public class CategoryPlotMoreCateTableDataContentPane extends CategoryPlotTableD private UIObserverListener uiobListener = null; - public ArrayList getBoxList() { + public List getBoxList() { return boxList; } From 8810f3c6956e3e2fc9cab3731eee052bb2b732aa Mon Sep 17 00:00:00 2001 From: mengao <283296419@qq.com> Date: Tue, 11 Jul 2017 13:30:04 +0800 Subject: [PATCH 11/50] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/report/CategoryPlotMoreCateReportDataContentPane.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/designer_chart/src/com/fr/design/mainframe/chart/gui/data/report/CategoryPlotMoreCateReportDataContentPane.java b/designer_chart/src/com/fr/design/mainframe/chart/gui/data/report/CategoryPlotMoreCateReportDataContentPane.java index 1cd4b8c09..d63bafbae 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/gui/data/report/CategoryPlotMoreCateReportDataContentPane.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/gui/data/report/CategoryPlotMoreCateReportDataContentPane.java @@ -22,6 +22,7 @@ import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; +import java.util.List; /** @@ -38,7 +39,7 @@ public class CategoryPlotMoreCateReportDataContentPane extends CategoryPlotRepor private ArrayList formualList = new ArrayList(); private UIObserverListener uiobListener = null; - public ArrayList getFormualList() { + public List getFormualList() { return formualList; } From 53aa00aa1a98b45b292a34ffda9f4650a562ea3f Mon Sep 17 00:00:00 2001 From: neil <459208047@qq.com> Date: Thu, 13 Jul 2017 14:46:58 +0800 Subject: [PATCH 12/50] =?UTF-8?q?REPORT-3272=20=E8=A1=A8=E5=8D=95=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E4=BF=9D=E5=AD=98=E9=97=AE=E9=A2=98.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer_form/src/com/fr/design/mainframe/JForm.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/designer_form/src/com/fr/design/mainframe/JForm.java b/designer_form/src/com/fr/design/mainframe/JForm.java index ba491e351..0a4aa9894 100644 --- a/designer_form/src/com/fr/design/mainframe/JForm.java +++ b/designer_form/src/com/fr/design/mainframe/JForm.java @@ -468,18 +468,21 @@ public class JForm extends JTemplate implements BaseJForm { @Override protected void applyUndoState(FormUndoState u) { try { - //JForm的target重置 - this.setTarget((Form) u.getForm().clone()); if (this.index == FORM_TAB) { + //JForm的target重置 + this.setTarget((Form) u.getForm().clone()); JForm.this.refreshRoot(); this.formDesign.getArea().setAreaSize(u.getAreaSize(), u.getHorizontalValue(), u.getVerticalValue(), u.getWidthValue(), u.getHeightValue(), u.getSlideValue()); //撤销的时候要重新选择的body布局 this.formDesign.getSelectionModel().setSelectedCreators(FormSelectionUtils.rebuildSelection(formDesign.getRootComponent(), formDesign.getRootComponent() == selectedBodyLayout() ? u.getSelectWidgets() : new Widget[]{selectedBodyLayout().toData()})); } else { + // 只在报表块里撤销是不需要修改外部form对象的, 因为编辑的是当前报表块. + // 修改了JForm的Target需要同步修改formDesign的Target. + Form undoForm = (Form) u.getForm().clone(); String widgetName = this.formDesign.getElementCaseContainerName(); //这儿太坑了,u.getForm() 与 getTarget内容不一样 - FormElementCaseProvider dataTable = getTarget().getElementCaseByName(widgetName); + FormElementCaseProvider dataTable = undoForm.getElementCaseByName(widgetName); this.reportComposite.setSelectedWidget(dataTable); //下面这句话是防止撤销之后直接退出编辑再编辑撤销的东西会回来,因为撤销不会保存EC formDesign.setElementCase(dataTable); From 23fd3ad8effcfa5ebe2e6355b1984a53318da90b Mon Sep 17 00:00:00 2001 From: neil <459208047@qq.com> Date: Thu, 13 Jul 2017 14:48:00 +0800 Subject: [PATCH 13/50] 1 --- designer_form/src/com/fr/design/mainframe/JForm.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer_form/src/com/fr/design/mainframe/JForm.java b/designer_form/src/com/fr/design/mainframe/JForm.java index 0a4aa9894..892cb8d91 100644 --- a/designer_form/src/com/fr/design/mainframe/JForm.java +++ b/designer_form/src/com/fr/design/mainframe/JForm.java @@ -478,7 +478,7 @@ public class JForm extends JTemplate implements BaseJForm { formDesign.getRootComponent() == selectedBodyLayout() ? u.getSelectWidgets() : new Widget[]{selectedBodyLayout().toData()})); } else { // 只在报表块里撤销是不需要修改外部form对象的, 因为编辑的是当前报表块. - // 修改了JForm的Target需要同步修改formDesign的Target. + // 修改了JForm的Target需 要同步修改formDesign的Target. Form undoForm = (Form) u.getForm().clone(); String widgetName = this.formDesign.getElementCaseContainerName(); //这儿太坑了,u.getForm() 与 getTarget内容不一样 From 9dcd2698c86b4236851d773ea9e5c78ffb1b3abd Mon Sep 17 00:00:00 2001 From: neil <459208047@qq.com> Date: Thu, 13 Jul 2017 14:48:13 +0800 Subject: [PATCH 14/50] 1 --- designer_form/src/com/fr/design/mainframe/JForm.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer_form/src/com/fr/design/mainframe/JForm.java b/designer_form/src/com/fr/design/mainframe/JForm.java index 892cb8d91..0a4aa9894 100644 --- a/designer_form/src/com/fr/design/mainframe/JForm.java +++ b/designer_form/src/com/fr/design/mainframe/JForm.java @@ -478,7 +478,7 @@ public class JForm extends JTemplate implements BaseJForm { formDesign.getRootComponent() == selectedBodyLayout() ? u.getSelectWidgets() : new Widget[]{selectedBodyLayout().toData()})); } else { // 只在报表块里撤销是不需要修改外部form对象的, 因为编辑的是当前报表块. - // 修改了JForm的Target需 要同步修改formDesign的Target. + // 修改了JForm的Target需要同步修改formDesign的Target. Form undoForm = (Form) u.getForm().clone(); String widgetName = this.formDesign.getElementCaseContainerName(); //这儿太坑了,u.getForm() 与 getTarget内容不一样 From 2bc7f74a3c70732bfb35298acd1a6a72499a0026 Mon Sep 17 00:00:00 2001 From: mengao <283296419@qq.com> Date: Thu, 13 Jul 2017 19:27:24 +0800 Subject: [PATCH 15/50] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E6=B2=A1=E7=94=A8?= =?UTF-8?q?=E5=88=B0=E7=9A=84=E5=BC=95=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer_base/src/com/fr/design/module/DesignModuleFactory.java | 1 - 1 file changed, 1 deletion(-) diff --git a/designer_base/src/com/fr/design/module/DesignModuleFactory.java b/designer_base/src/com/fr/design/module/DesignModuleFactory.java index 1e5b4d1ed..2a4342a7d 100644 --- a/designer_base/src/com/fr/design/module/DesignModuleFactory.java +++ b/designer_base/src/com/fr/design/module/DesignModuleFactory.java @@ -2,7 +2,6 @@ package com.fr.design.module; import com.fr.base.FRContext; import com.fr.base.chart.BaseChartCollection; -import com.fr.chart.chartattr.ChartCollection; import com.fr.design.gui.chart.BaseChartPropertyPane; import com.fr.design.gui.chart.MiddleChartComponent; import com.fr.design.gui.chart.MiddleChartDialog; From 842f99ec4bb0eb6228b97ad87753c4b0fddb711f Mon Sep 17 00:00:00 2001 From: mengao <283296419@qq.com> Date: Thu, 20 Jul 2017 14:29:22 +0800 Subject: [PATCH 16/50] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=80=81=E5=9B=BE?= =?UTF-8?q?=E8=A1=A8=E9=82=A3=E8=BE=B9=E6=95=B0=E6=8D=AE=E5=A4=84=E7=90=86?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E7=9A=84=E4=B8=80=E4=BA=9B=E9=97=AE=E9=A2=98?= =?UTF-8?q?=20=E4=BF=AE=E6=94=B9=E5=A4=9A=E5=88=86=E7=B1=BB=E8=BD=B4bug=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=A4=9A=E5=88=86=E7=B1=BB=E6=97=B6=E7=9B=91?= =?UTF-8?q?=E6=8E=A7=E5=88=B7=E6=96=B0=E7=9A=84=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../report/CategoryPlotMoreCateReportDataContentPane.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/designer_chart/src/com/fr/design/mainframe/chart/gui/data/report/CategoryPlotMoreCateReportDataContentPane.java b/designer_chart/src/com/fr/design/mainframe/chart/gui/data/report/CategoryPlotMoreCateReportDataContentPane.java index d63bafbae..eb7ad057e 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/gui/data/report/CategoryPlotMoreCateReportDataContentPane.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/gui/data/report/CategoryPlotMoreCateReportDataContentPane.java @@ -3,9 +3,9 @@ package com.fr.design.mainframe.chart.gui.data.report; import com.fr.base.BaseUtils; import com.fr.base.Utils; import com.fr.base.chart.chartdata.TopDefinitionProvider; -import com.fr.chart.chartattr.Axis; import com.fr.chart.chartattr.Bar2DPlot; import com.fr.chart.chartattr.ChartCollection; +import com.fr.chart.chartattr.Plot; import com.fr.chart.chartdata.NormalReportDataDefinition; import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserverListener; @@ -178,17 +178,17 @@ public class CategoryPlotMoreCateReportDataContentPane extends CategoryPlotRepor super.updateBean(collection); TopDefinitionProvider definition = collection.getSelectedChart().getFilterDefinition(); - Axis axis = collection.getSelectedChart().getPlot().getxAxis(); + Plot plot = collection.getSelectedChart().getPlot(); if (definition instanceof NormalReportDataDefinition) { NormalReportDataDefinition reportDefinition = (NormalReportDataDefinition) definition; reportDefinition.clearMoreCate(); - updateMoreCate(reportDefinition, axis); + updateMoreCate(reportDefinition, plot); } } - protected void updateMoreCate(NormalReportDataDefinition reportDefinition, Axis axis) { + protected void updateMoreCate(NormalReportDataDefinition reportDefinition, Plot plot) { for (int i = 0, size = formualList.size(); i < size; i++) { TinyFormulaPane pane = formualList.get(i); reportDefinition.addMoreCate(canBeFormula(pane.updateBean())); From 97d781caaf74a6f26ab98b15143a2333c6527d90 Mon Sep 17 00:00:00 2001 From: mengao <283296419@qq.com> Date: Fri, 21 Jul 2017 11:47:36 +0800 Subject: [PATCH 17/50] =?UTF-8?q?=E5=AE=89=E8=A3=85=E5=B9=B3=E5=8F=B0?= =?UTF-8?q?=E5=86=85=E6=89=93=E5=BC=80=E6=8F=92=E4=BB=B6=EF=BC=8C=E5=9B=BE?= =?UTF-8?q?=E8=A1=A8=E8=B6=85=E9=93=BE=E4=B8=AD=E6=B7=BB=E5=8A=A0=E7=9B=B8?= =?UTF-8?q?=E5=BA=94=E7=9A=84=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gui/controlpane/AbstractNameableCreator.java | 9 +++++++++ .../fr/design/gui/controlpane/NameableCreator.java | 5 ++++- .../chart/gui/other/ChartInteractivePane.java | 11 +++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/designer_base/src/com/fr/design/gui/controlpane/AbstractNameableCreator.java b/designer_base/src/com/fr/design/gui/controlpane/AbstractNameableCreator.java index 36a760b5b..b3bb6f9d5 100644 --- a/designer_base/src/com/fr/design/gui/controlpane/AbstractNameableCreator.java +++ b/designer_base/src/com/fr/design/gui/controlpane/AbstractNameableCreator.java @@ -4,6 +4,7 @@ import com.fr.base.BaseUtils; import com.fr.design.beans.BasicBeanPane; import com.fr.general.ComparatorUtils; import com.fr.general.NameObject; +import com.fr.js.AbstractJavaScript; import javax.swing.*; @@ -70,6 +71,14 @@ public abstract class AbstractNameableCreator implements NameableCreator { return this.clazzOfEditor; } + /** + * get clazzOfObject + * @return clazzOfObject + */ + public Class getClazz() { + return this.clazzOfObject; + } + /** * * @param ob diff --git a/designer_base/src/com/fr/design/gui/controlpane/NameableCreator.java b/designer_base/src/com/fr/design/gui/controlpane/NameableCreator.java index f497be1e6..eb26e2181 100644 --- a/designer_base/src/com/fr/design/gui/controlpane/NameableCreator.java +++ b/designer_base/src/com/fr/design/gui/controlpane/NameableCreator.java @@ -2,6 +2,7 @@ package com.fr.design.gui.controlpane; import com.fr.design.beans.BasicBeanPane; import com.fr.design.gui.ilist.ListModelElement; +import com.fr.js.AbstractJavaScript; import com.fr.stable.Nameable; import javax.swing.*; @@ -16,7 +17,9 @@ public interface NameableCreator { public Nameable createNameable(UnrepeatedNameHelper helper); public Class getUpdatePane(); - + + public Class getClazz(); + public Object acceptObject2Populate(Object ob); public void saveUpdatedBean(ListModelElement wrapper, Object bean); diff --git a/designer_chart/src/com/fr/design/mainframe/chart/gui/other/ChartInteractivePane.java b/designer_chart/src/com/fr/design/mainframe/chart/gui/other/ChartInteractivePane.java index f8b002bcf..0250000f9 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/gui/other/ChartInteractivePane.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/gui/other/ChartInteractivePane.java @@ -12,6 +12,7 @@ import com.fr.chart.chartdata.GisMapTableDefinition; import com.fr.chart.web.ChartHyperPoplink; import com.fr.chart.web.ChartHyperRelateCellLink; import com.fr.chart.web.ChartHyperRelateFloatLink; +import com.fr.design.ExtraDesignClassManager; import com.fr.design.beans.BasicBeanPane; import com.fr.design.chart.javascript.ChartEmailPane; import com.fr.design.chart.series.SeriesCondition.impl.ChartHyperPoplinkPane; @@ -21,6 +22,8 @@ import com.fr.design.chart.series.SeriesCondition.impl.FormHyperlinkPane; import com.fr.design.dialog.BasicScrollPane; import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserverListener; +import com.fr.design.fun.HyperlinkProvider; +import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.frpane.UIBubbleFloatPane; import com.fr.design.gui.frpane.UICorrelationComboBoxPane; import com.fr.design.gui.ibutton.UIButton; @@ -53,6 +56,7 @@ import java.text.DecimalFormat; import java.text.Format; import java.util.ArrayList; import java.util.List; +import java.util.Set; public class ChartInteractivePane extends BasicScrollPane implements UIObserver{ private static final long serialVersionUID = 3477409806918835992L; @@ -655,6 +659,13 @@ public class ChartInteractivePane extends BasicScrollPane implements UIOb private void populateHyperlink(Plot plot) { HashMap paneMap = renewMapWithPlot(plot); + //安装平台内打开插件时,添加相应按钮 + Set providers = ExtraDesignClassManager.getInstance().getArray(HyperlinkProvider.XML_TAG); + for (HyperlinkProvider provider : providers) { + NameableCreator nc = provider.createHyperlinkCreator(); + paneMap.put(nc.getClazz(), nc.getUpdatePane()); + } + List list = refreshList(paneMap); superLink.refreshMenuAndAddMenuAction(list); From 59696f6e66523c09915a9d9071f5a92a9021d0de Mon Sep 17 00:00:00 2001 From: mengao <283296419@qq.com> Date: Fri, 21 Jul 2017 17:11:52 +0800 Subject: [PATCH 18/50] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/gui/controlpane/AbstractNameableCreator.java | 4 ++-- .../src/com/fr/design/gui/controlpane/NameableCreator.java | 4 ++-- .../mainframe/chart/gui/other/ChartInteractivePane.java | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/designer_base/src/com/fr/design/gui/controlpane/AbstractNameableCreator.java b/designer_base/src/com/fr/design/gui/controlpane/AbstractNameableCreator.java index b3bb6f9d5..d8eae8fd2 100644 --- a/designer_base/src/com/fr/design/gui/controlpane/AbstractNameableCreator.java +++ b/designer_base/src/com/fr/design/gui/controlpane/AbstractNameableCreator.java @@ -4,7 +4,7 @@ import com.fr.base.BaseUtils; import com.fr.design.beans.BasicBeanPane; import com.fr.general.ComparatorUtils; import com.fr.general.NameObject; -import com.fr.js.AbstractJavaScript; +import com.fr.js.JavaScript; import javax.swing.*; @@ -75,7 +75,7 @@ public abstract class AbstractNameableCreator implements NameableCreator { * get clazzOfObject * @return clazzOfObject */ - public Class getClazz() { + public Class getHyperlink() { return this.clazzOfObject; } diff --git a/designer_base/src/com/fr/design/gui/controlpane/NameableCreator.java b/designer_base/src/com/fr/design/gui/controlpane/NameableCreator.java index eb26e2181..ec03b371f 100644 --- a/designer_base/src/com/fr/design/gui/controlpane/NameableCreator.java +++ b/designer_base/src/com/fr/design/gui/controlpane/NameableCreator.java @@ -2,7 +2,7 @@ package com.fr.design.gui.controlpane; import com.fr.design.beans.BasicBeanPane; import com.fr.design.gui.ilist.ListModelElement; -import com.fr.js.AbstractJavaScript; +import com.fr.js.JavaScript; import com.fr.stable.Nameable; import javax.swing.*; @@ -18,7 +18,7 @@ public interface NameableCreator { public Class getUpdatePane(); - public Class getClazz(); + public Class getHyperlink(); public Object acceptObject2Populate(Object ob); diff --git a/designer_chart/src/com/fr/design/mainframe/chart/gui/other/ChartInteractivePane.java b/designer_chart/src/com/fr/design/mainframe/chart/gui/other/ChartInteractivePane.java index 0250000f9..ac8c1efe6 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/gui/other/ChartInteractivePane.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/gui/other/ChartInteractivePane.java @@ -663,7 +663,7 @@ public class ChartInteractivePane extends BasicScrollPane implements UIOb Set providers = ExtraDesignClassManager.getInstance().getArray(HyperlinkProvider.XML_TAG); for (HyperlinkProvider provider : providers) { NameableCreator nc = provider.createHyperlinkCreator(); - paneMap.put(nc.getClazz(), nc.getUpdatePane()); + paneMap.put(nc.getHyperlink(), nc.getUpdatePane()); } List list = refreshList(paneMap); From bcd4a7dedceedb50692adcb4ccfe6d0104e49f9f Mon Sep 17 00:00:00 2001 From: richie Date: Tue, 25 Jul 2017 13:56:57 +0800 Subject: [PATCH 19/50] =?UTF-8?q?=E5=A2=9E=E5=8A=A0license?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- LICENSE | 674 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 674 insertions(+) create mode 100755 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100755 index 000000000..9cecc1d46 --- /dev/null +++ b/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + {one line to give the program's name and a brief idea of what it does.} + Copyright (C) {year} {name of author} + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + {project} Copyright (C) {year} {fullname} + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. From 869e5c633e10cb66f7fc2497a0d5d86fa7d077ec Mon Sep 17 00:00:00 2001 From: mengao <283296419@qq.com> Date: Wed, 26 Jul 2017 17:15:26 +0800 Subject: [PATCH 20/50] =?UTF-8?q?=E5=9C=B0=E5=9B=BE=E8=BF=9C=E7=A8=8B?= =?UTF-8?q?=E8=AE=BE=E8=AE=A1=E7=9A=84=E6=97=B6=E5=80=99=E5=9C=A8=E5=86=99?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E7=9A=84=E6=97=B6=E5=80=99=E6=9B=B4=E6=96=B0?= =?UTF-8?q?mapAttr?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/chart/report/MapCubeLayerPane.java | 4 +- .../chart/report/MapCubeSetDataPane.java | 2 +- .../PlotSeries/AbstrctMapAttrEditPane.java | 2 +- .../series/PlotSeries/MapCustomPane.java | 2 +- .../PlotSeries/MapDefiAreaNamePane.java | 4 +- .../PlotSeries/MapGroupExtensionPane.java | 2 +- .../series/PlotSeries/MapImageEditPane.java | 49 +++++++------------ .../PlotSeries/UIGroupExtensionPane.java | 2 +- .../com/fr/design/mainframe/MapEditPane.java | 4 +- 9 files changed, 30 insertions(+), 41 deletions(-) diff --git a/designer_chart/src/com/fr/design/chart/report/MapCubeLayerPane.java b/designer_chart/src/com/fr/design/chart/report/MapCubeLayerPane.java index 461fe220a..5d54f7853 100644 --- a/designer_chart/src/com/fr/design/chart/report/MapCubeLayerPane.java +++ b/designer_chart/src/com/fr/design/chart/report/MapCubeLayerPane.java @@ -1,10 +1,10 @@ package com.fr.design.chart.report; +import com.fr.base.MapSvgAttr; +import com.fr.base.MapSvgXMLHelper; import com.fr.base.MapXMLHelper; import com.fr.base.Utils; import com.fr.chart.base.ChartConstants; -import com.fr.chart.base.MapSvgAttr; -import com.fr.chart.base.MapSvgXMLHelper; import com.fr.chart.chartglyph.MapAttr; import com.fr.design.DesignerEnvManager; import com.fr.design.beans.BasicBeanPane; diff --git a/designer_chart/src/com/fr/design/chart/report/MapCubeSetDataPane.java b/designer_chart/src/com/fr/design/chart/report/MapCubeSetDataPane.java index 4c175500e..3110e241b 100644 --- a/designer_chart/src/com/fr/design/chart/report/MapCubeSetDataPane.java +++ b/designer_chart/src/com/fr/design/chart/report/MapCubeSetDataPane.java @@ -1,7 +1,7 @@ package com.fr.design.chart.report; +import com.fr.base.MapSvgXMLHelper; import com.fr.base.MapXMLHelper; -import com.fr.chart.base.MapSvgXMLHelper; import com.fr.design.beans.BasicBeanPane; import com.fr.design.editor.ValueEditorPane; import com.fr.design.editor.ValueEditorPaneFactory; diff --git a/designer_chart/src/com/fr/design/chart/series/PlotSeries/AbstrctMapAttrEditPane.java b/designer_chart/src/com/fr/design/chart/series/PlotSeries/AbstrctMapAttrEditPane.java index d2d61909b..254dfaec1 100644 --- a/designer_chart/src/com/fr/design/chart/series/PlotSeries/AbstrctMapAttrEditPane.java +++ b/designer_chart/src/com/fr/design/chart/series/PlotSeries/AbstrctMapAttrEditPane.java @@ -1,6 +1,6 @@ package com.fr.design.chart.series.PlotSeries; -import com.fr.chart.base.MapSvgAttr; +import com.fr.base.MapSvgAttr; /** * Created by IntelliJ IDEA. diff --git a/designer_chart/src/com/fr/design/chart/series/PlotSeries/MapCustomPane.java b/designer_chart/src/com/fr/design/chart/series/PlotSeries/MapCustomPane.java index d844631c0..49fa97eee 100644 --- a/designer_chart/src/com/fr/design/chart/series/PlotSeries/MapCustomPane.java +++ b/designer_chart/src/com/fr/design/chart/series/PlotSeries/MapCustomPane.java @@ -1,9 +1,9 @@ package com.fr.design.chart.series.PlotSeries; import com.fr.base.FRContext; +import com.fr.base.MapSvgAttr; import com.fr.base.TableData; import com.fr.base.Utils; -import com.fr.chart.base.MapSvgAttr; import com.fr.data.impl.EmbeddedTableData; import com.fr.design.beans.BasicBeanPane; import com.fr.design.data.DesignTableDataManager; diff --git a/designer_chart/src/com/fr/design/chart/series/PlotSeries/MapDefiAreaNamePane.java b/designer_chart/src/com/fr/design/chart/series/PlotSeries/MapDefiAreaNamePane.java index ca8d3a67d..0a3928ae4 100644 --- a/designer_chart/src/com/fr/design/chart/series/PlotSeries/MapDefiAreaNamePane.java +++ b/designer_chart/src/com/fr/design/chart/series/PlotSeries/MapDefiAreaNamePane.java @@ -1,8 +1,8 @@ package com.fr.design.chart.series.PlotSeries; +import com.fr.base.MapSvgAttr; +import com.fr.base.MapSvgXMLHelper; import com.fr.base.Utils; -import com.fr.chart.base.MapSvgAttr; -import com.fr.chart.base.MapSvgXMLHelper; import com.fr.design.beans.BasicBeanPane; import com.fr.design.data.tabledata.wrapper.TableDataWrapper; import com.fr.design.editor.ValueEditorPane; diff --git a/designer_chart/src/com/fr/design/chart/series/PlotSeries/MapGroupExtensionPane.java b/designer_chart/src/com/fr/design/chart/series/PlotSeries/MapGroupExtensionPane.java index f1f1b3deb..74a8e687f 100644 --- a/designer_chart/src/com/fr/design/chart/series/PlotSeries/MapGroupExtensionPane.java +++ b/designer_chart/src/com/fr/design/chart/series/PlotSeries/MapGroupExtensionPane.java @@ -1 +1 @@ -package com.fr.design.chart.series.PlotSeries; import com.fr.base.*; import com.fr.chart.base.MapSvgAttr; import com.fr.chart.base.MapSvgXMLHelper; import com.fr.chart.chartattr.MapPlot; import com.fr.chart.chartglyph.MapShapeValue; import com.fr.design.constants.UIConstants; import com.fr.design.DesignerEnvManager; import com.fr.design.event.ChangeEvent; import com.fr.design.event.ChangeListener; import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserverListener; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerFrame; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.DialogActionAdapter; import com.fr.general.ComparatorUtils; import com.fr.general.FRLogger; import com.fr.general.Inter; import com.fr.stable.CoreConstants; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.stable.SvgProvider; import javax.swing.*; import javax.swing.event.ListSelectionEvent; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseEvent; import java.awt.geom.RoundRectangle2D; import java.util.ArrayList; /** * Created by IntelliJ IDEA. * Author : Richer * Version: 7.0.3 * Date: 12-12-29 * Time: 下午2:41 */ public class MapGroupExtensionPane extends BasicPane implements UIObserver { private static final String[] TYPE_NAMES = new String[]{ Inter.getLocText("FR-Chart-World_Map"), Inter.getLocText("FR-Chart-State_Map"), Inter.getLocText("FR-Chart-Province_Map"), Inter.getLocText("FR-Chart-Custom_Map")}; private static final int WORD = 0; private static final int NATION = 1; private static final int STATE = 2; private static final int USER = 3; private static final int OFFSET_X = 800; private static final int OFFSET_Y = 200; private UIGroupExtensionPane groupExtensionPane; private UIButton addButton; private JPopupMenu popupMenu; private ArrayList changeListeners = new ArrayList(); private boolean hasPopulated = false; @Override protected String title4PopupWindow() { return "Map"; } public MapGroupExtensionPane() { setLayout(new BorderLayout()); groupExtensionPane = new UIGroupExtensionPane(TYPE_NAMES){ /** * 新添加的数据的序号 * @param data 数据 */ protected void dealNewAddedDataIndex(Object data){ String newName = (String)data; MapSvgXMLHelper helper = MapSvgXMLHelper.getInstance(); if(helper.getNewMapAttr(newName) != null){ return; } MapSvgAttr attr = new MapSvgAttr(); attr.setFilePath(MapSvgXMLHelper.customMapPath() + CoreConstants.SEPARATOR + newName + ".svg"); helper.addNewSvgMaps(attr.getName(), attr); } /** * 一次鼠标的点击会有两次事件响应(按下和释放)。前者的事件属性中getValueIsAdjusting()=true,后者是false。 * 是否响应list值改变 * @return 鼠标按下时不响应,先响应mousePress事件,在鼠标释放是再响应list值改编的事件,并且点击删除不触发更新,并且populate后触发更新 */ protected boolean isRespondToValueChange(ListSelectionEvent e){ return !e.getValueIsAdjusting() && !this.isPressOnDelete() && hasPopulated; } }; groupExtensionPane.addSelectionChangeListener(new ChangeListener() { @Override public void fireChanged(ChangeEvent event) { fireStateChange(); } }); groupExtensionPane.addItemEditListener(new ChangeListener() { @Override public void fireChanged(ChangeEvent event) { doEdit(event); } }); groupExtensionPane.addDeleteListener(new ChangeListener() { @Override public void fireChanged(ChangeEvent event) { //这么写有点问题 String oldName = Utils.objectToString(groupExtensionPane.getSelectedObject()); saveMapInfo(oldName); } }); setPreferredSize(new Dimension(400, 210)); add(groupExtensionPane, BorderLayout.CENTER); addButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/add.png")) { @Override protected void paintBorder(Graphics g) { Graphics2D g2d = (Graphics2D) g; g2d.setStroke(UIConstants.BS); Shape shape = new RoundRectangle2D.Float(0.5f, 0.5f, getWidth() - 1, getHeight() - 1, UIConstants.ARC, UIConstants.ARC); g2d.setColor(UIConstants.LINE_COLOR); g2d.draw(shape); } }; addButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { popupMenu.show(MapGroupExtensionPane.this, addButton.getX() + 1, addButton.getY() + addButton.getHeight()); } }); add(addButton, BorderLayout.SOUTH); initPopupMenu(); } private void initPopupMenu() { popupMenu = new JPopupMenu() { @Override public Dimension getPreferredSize() { Dimension dimension = new Dimension(); dimension.height = super.getPreferredSize().height; dimension.width = addButton.getWidth() - 2; return dimension; } }; JMenuItem worldMap = new JMenuItem(TYPE_NAMES[WORD]); popupMenu.add(worldMap); worldMap.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { groupExtensionPane.addData(TYPE_NAMES[WORD], TYPE_NAMES[WORD], true); } }); JMenuItem countMap = new JMenuItem(TYPE_NAMES[NATION]); popupMenu.add(countMap); countMap.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { groupExtensionPane.addData(TYPE_NAMES[NATION], TYPE_NAMES[NATION], true); } }); JMenuItem proMap = new JMenuItem(TYPE_NAMES[STATE]); popupMenu.add(proMap); proMap.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { groupExtensionPane.addData(TYPE_NAMES[STATE], TYPE_NAMES[STATE], true); } }); JMenuItem menu = new JMenuItem(TYPE_NAMES[USER]); popupMenu.add(menu); menu.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { groupExtensionPane.addData(TYPE_NAMES[USER], TYPE_NAMES[USER], true); } }); } private void doEdit(ChangeEvent e) { MouseEvent event = (MouseEvent) e.getSource(); JPopupMenu editPopMenu = new JPopupMenu(); final String oldName = Utils.objectToString(groupExtensionPane.getSelectedObject()); editPopMenu.add(createAreaItem(oldName)); editPopMenu.add(createMarkerItem(oldName)); editPopMenu.add(createLayerItem(oldName)); editPopMenu.add(createRenameItem()); editPopMenu.show(MapGroupExtensionPane.this, event.getXOnScreen() - OFFSET_X, event.getYOnScreen() - OFFSET_Y); } private void mapCheckBeforeEdit(String name){ if(MapSvgXMLHelper.getInstance().containsMapName(name) || MapSvgXMLHelper.getInstance().getNewMapAttr(name)!=null){ return; } MapSvgAttr attr = new MapSvgAttr(); attr.setFilePath(MapSvgXMLHelper.customMapPath() + CoreConstants.SEPARATOR + name + ".svg"); MapSvgXMLHelper.getInstance().addNewSvgMaps(name,attr); } private JMenuItem createAreaItem(final String oldName) { JMenuItem editFileItem = new JMenuItem(Inter.getLocText(new String[]{"Edit", "Image", "Filed"})); editFileItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { final MapCustomPane image = new MapCustomPane(); image.setImageSelectType(MapShapeValue.AREA); image.populateBean(oldName); image.setTypeNameAndMapName(groupExtensionPane.getSelectedType(), Utils.objectToString(groupExtensionPane.getSelectedObject())); mapCheckBeforeEdit(oldName); final Image oldImage = getMapImage(oldName); BasicDialog dialog = image.showMediumWindow(SwingUtilities.getWindowAncestor(MapGroupExtensionPane.this), new DialogActionAdapter() { public void doOk() { image.updateBean(); // 比较两个前后的名字是否相同, 是图片 如果图片不同, 则直接比较 Image newImage = getMapImage(oldName); if(!ComparatorUtils.equals(oldImage, newImage)) { fireStateChange(); } //versionID递增 MapSvgAttr old = MapSvgXMLHelper.getInstance().getMapAttr(oldName); if(old != null) { old.addVersionID(); } saveMapInfo(oldName); refresh(); } }); dialog.setVisible(true); } }); return editFileItem; } //根据地图的名字返回地图的图片 private Image getMapImage(String mapName) { if (MapSvgXMLHelper.getInstance().containsMapName(mapName)) { MapSvgAttr mapAttr = MapSvgXMLHelper.getInstance().getMapAttr(mapName); if(mapAttr == null) { return null; } return mapAttr.getMapImage(); } return null; } private JMenuItem createMarkerItem(final String oldName) { JMenuItem editMarkerItem = new JMenuItem(Inter.getLocText(new String[]{"Edit", "Image", "Marker"})); editMarkerItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { final MapCustomPane image = new MapCustomPane(); image.setImageSelectType(MapShapeValue.POINT); image.populateBean(oldName); mapCheckBeforeEdit(oldName); final Image oldImage = getMapImage(oldName); BasicDialog dialog = image.showMediumWindow(SwingUtilities.getWindowAncestor(image), new DialogActionAdapter() { public void doOk() { image.updateBean(); Image newImage = getMapImage(oldName); if(!ComparatorUtils.equals(oldImage, newImage)) { fireStateChange(); } //versionID递增 MapSvgAttr old = MapSvgXMLHelper.getInstance().getMapAttr(oldName); if(old != null) { old.addVersionID(); } saveMapInfo(oldName); refresh(); } }); dialog.setVisible(true); } }); return editMarkerItem; } private JMenuItem createLayerItem(final String oldName) { JMenuItem corrItem = new JMenuItem(Inter.getLocText(new String[]{"Filed", "Corresponding_Fields"})); corrItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { final MapDefiAreaNamePane namedPane = new MapDefiAreaNamePane(); namedPane.populateBean(oldName); mapCheckBeforeEdit(oldName); BasicDialog dialog = namedPane.showMediumWindow(SwingUtilities.getWindowAncestor(namedPane), new DialogActionAdapter() { public void doOk() { namedPane.updateBean();// 地图的名称 value对应情况 MapSvgAttr old = MapSvgXMLHelper.getInstance().getMapAttr(oldName); if(old != null) { old.addVersionID(); } saveMapInfo(oldName); } }); dialog.setVisible(true); refresh(); } }); return corrItem; } private void showRenameWaring(String newName){ JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), "\"" + newName + "\"" + Inter.getLocText("Utils-has_been_existed") + "!", Inter.getLocText("FR-Designer_Alert"), JOptionPane.WARNING_MESSAGE); } private JMenuItem createRenameItem() { JMenuItem renameItem = new JMenuItem(Inter.getLocText("FR-Chart-Map_Rename")); renameItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String newName = JOptionPane.showInputDialog(DesignerContext.getDesignerFrame().getContentPane(), Inter.getLocText("FR-Chart-Map_Rename"), groupExtensionPane.getSelectedObject()); if (StringUtils.isNotBlank(newName)) { String oldName = Utils.objectToString(groupExtensionPane.getSelectedObject()); if(ComparatorUtils.equals(oldName, newName)){ return; } //本地在看看临时的helper里面有没有 if(MapSvgXMLHelper.getInstance().getNewMapAttr(newName) != null){ showRenameWaring(newName); return; } try{//提醒名字已存在 if(FRContext.getCurrentEnv().fileExists(StableUtils.pathJoin( new String[]{MapSvgXMLHelper.relativeDefaultMapPath(),newName+SvgProvider.EXTENSION}))){ showRenameWaring(newName); return; } if(FRContext.getCurrentEnv().fileExists(StableUtils.pathJoin( new String[]{MapSvgXMLHelper.relativeCustomMapPath(), newName + SvgProvider.EXTENSION}))){ showRenameWaring(newName); return; } MapSvgAttr editingAttr = MapSvgXMLHelper.getInstance().getMapAttr(oldName); if(editingAttr == null){ editingAttr = MapSvgXMLHelper.getInstance().getNewMapAttr(oldName); } if( editingAttr == null) { return; } editingAttr.renameMap(newName); groupExtensionPane.setValueAtCurrentSelectIndex(newName); fireStateChange(); saveMapInfo(newName); FRContext.getCurrentEnv().deleteFile( StableUtils.pathJoin(new String[]{MapSvgXMLHelper.relativeDefaultMapPath(),oldName+SvgProvider.EXTENSION})); FRContext.getCurrentEnv().deleteFile( StableUtils.pathJoin(new String[]{MapSvgXMLHelper.relativeCustomMapPath(),oldName+SvgProvider.EXTENSION})); refresh(); }catch (Exception exp){ FRLogger.getLogger().error(exp.getMessage()); } } } }); return renameItem; } private void refresh() { this.validate(); this.repaint(); DesignerFrame frame = DesignerContext.getDesignerFrame(); if(frame != null) { frame.repaint();//kunsnat: 图表属性没变, 只是读取时 内容变化. } } //保存修改过的地图信息 private void saveMapInfo(final String mapName) { SwingWorker worker = new SwingWorker() { @Override protected Integer doInBackground() throws Exception { MapSvgAttr attr = MapSvgXMLHelper.getInstance().getMapAttr(mapName);// 只有在编辑地图时才需要储存相关数据 @kuns if(attr != null){ attr.writeBack(mapName); } return 0; } @Override protected void done() { FRLogger.getLogger().info(Inter.getLocText("FR-Chart-Map_Saved")); // 地图已经保存. } }; worker.execute(); DesignerEnvManager.addWorkers(worker); } private void fireStateChange() { for (int i = changeListeners.size(); i > 0; i--) { changeListeners.get(i - 1).stateChanged(new javax.swing.event.ChangeEvent(this)); } } /** * 更新地图属性 * @return 返回地图名称. */ public String updateBean(MapPlot plot) { if(!hasPopulated){ this.populateBean(plot); hasPopulated = true; } MapHelper helper = plot.isSvgMap() ? MapSvgXMLHelper.getInstance() : MapXMLHelper.getInstance(); helper.clearCateNames(); for (String type : TYPE_NAMES) { Object[] datas = groupExtensionPane.getData(type); for (Object name : datas) { helper.addCateNames(type, name); } } return Utils.objectToString(groupExtensionPane.getSelectedObject()); } /** * 更新地图名称 * @param mapPlot 地图 */ public void populateBean(MapPlot mapPlot) { hasPopulated = false; groupExtensionPane.clearData(); for (String type : TYPE_NAMES) { MapHelper helper = mapPlot.isSvgMap() ? MapSvgXMLHelper.getInstance() : MapXMLHelper.getInstance(); java.util.List list = helper.getNamesListWithCateName(type); for (Object name : list) { groupExtensionPane.addData(name, type); } } groupExtensionPane.setSelectedObject(mapPlot.getMapName()); hasPopulated = true; } /** * 给组件登记一个观察者监听事件 * * @param listener 观察者监听事件 */ public void registerChangeListener(final UIObserverListener listener) { changeListeners.add(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent e) { listener.doChange(); } }); } /** * 组件是否需要响应添加的观察者事件 * * @return 如果需要响应观察者事件则返回true,否则返回false */ public boolean shouldResponseChangeListener() { return true; } public void setEnabled(boolean isEnabled){ super.setEnabled(isEnabled); addButton.setEnabled(isEnabled); popupMenu.setEnabled(isEnabled); groupExtensionPane.setEnabled(isEnabled); } } \ No newline at end of file +package com.fr.design.chart.series.PlotSeries; import com.fr.base.*; import com.fr.chart.chartattr.MapPlot; import com.fr.chart.chartglyph.MapShapeValue; import com.fr.design.DesignerEnvManager; import com.fr.design.constants.UIConstants; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.event.ChangeEvent; import com.fr.design.event.ChangeListener; import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserverListener; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerFrame; import com.fr.general.ComparatorUtils; import com.fr.general.FRLogger; import com.fr.general.Inter; import com.fr.stable.CoreConstants; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.stable.SvgProvider; import javax.swing.*; import javax.swing.event.ListSelectionEvent; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseEvent; import java.awt.geom.RoundRectangle2D; import java.util.ArrayList; /** * Created by IntelliJ IDEA. * Author : Richer * Version: 7.0.3 * Date: 12-12-29 * Time: 下午2:41 */ public class MapGroupExtensionPane extends BasicPane implements UIObserver { private static final String[] TYPE_NAMES = new String[]{ Inter.getLocText("FR-Chart-World_Map"), Inter.getLocText("FR-Chart-State_Map"), Inter.getLocText("FR-Chart-Province_Map"), Inter.getLocText("FR-Chart-Custom_Map")}; private static final int WORD = 0; private static final int NATION = 1; private static final int STATE = 2; private static final int USER = 3; private static final int OFFSET_X = 800; private static final int OFFSET_Y = 200; private UIGroupExtensionPane groupExtensionPane; private UIButton addButton; private JPopupMenu popupMenu; private ArrayList changeListeners = new ArrayList(); private boolean hasPopulated = false; @Override protected String title4PopupWindow() { return "Map"; } public MapGroupExtensionPane() { setLayout(new BorderLayout()); groupExtensionPane = new UIGroupExtensionPane(TYPE_NAMES){ /** * 新添加的数据的序号 * @param data 数据 */ protected void dealNewAddedDataIndex(Object data){ String newName = (String)data; MapSvgXMLHelper helper = MapSvgXMLHelper.getInstance(); if(helper.getNewMapAttr(newName) != null){ return; } MapSvgAttr attr = new MapSvgAttr(); attr.setFilePath(MapSvgXMLHelper.customMapPath() + CoreConstants.SEPARATOR + newName + ".svg"); helper.addNewSvgMaps(attr.getName(), attr); } /** * 一次鼠标的点击会有两次事件响应(按下和释放)。前者的事件属性中getValueIsAdjusting()=true,后者是false。 * 是否响应list值改变 * @return 鼠标按下时不响应,先响应mousePress事件,在鼠标释放是再响应list值改编的事件,并且点击删除不触发更新,并且populate后触发更新 */ protected boolean isRespondToValueChange(ListSelectionEvent e){ return !e.getValueIsAdjusting() && !this.isPressOnDelete() && hasPopulated; } }; groupExtensionPane.addSelectionChangeListener(new ChangeListener() { @Override public void fireChanged(ChangeEvent event) { fireStateChange(); } }); groupExtensionPane.addItemEditListener(new ChangeListener() { @Override public void fireChanged(ChangeEvent event) { doEdit(event); } }); groupExtensionPane.addDeleteListener(new ChangeListener() { @Override public void fireChanged(ChangeEvent event) { //这么写有点问题 String oldName = Utils.objectToString(groupExtensionPane.getSelectedObject()); saveMapInfo(oldName); } }); setPreferredSize(new Dimension(400, 210)); add(groupExtensionPane, BorderLayout.CENTER); addButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/add.png")) { @Override protected void paintBorder(Graphics g) { Graphics2D g2d = (Graphics2D) g; g2d.setStroke(UIConstants.BS); Shape shape = new RoundRectangle2D.Float(0.5f, 0.5f, getWidth() - 1, getHeight() - 1, UIConstants.ARC, UIConstants.ARC); g2d.setColor(UIConstants.LINE_COLOR); g2d.draw(shape); } }; addButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { popupMenu.show(MapGroupExtensionPane.this, addButton.getX() + 1, addButton.getY() + addButton.getHeight()); } }); add(addButton, BorderLayout.SOUTH); initPopupMenu(); } private void initPopupMenu() { popupMenu = new JPopupMenu() { @Override public Dimension getPreferredSize() { Dimension dimension = new Dimension(); dimension.height = super.getPreferredSize().height; dimension.width = addButton.getWidth() - 2; return dimension; } }; JMenuItem worldMap = new JMenuItem(TYPE_NAMES[WORD]); popupMenu.add(worldMap); worldMap.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { groupExtensionPane.addData(TYPE_NAMES[WORD], TYPE_NAMES[WORD], true); } }); JMenuItem countMap = new JMenuItem(TYPE_NAMES[NATION]); popupMenu.add(countMap); countMap.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { groupExtensionPane.addData(TYPE_NAMES[NATION], TYPE_NAMES[NATION], true); } }); JMenuItem proMap = new JMenuItem(TYPE_NAMES[STATE]); popupMenu.add(proMap); proMap.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { groupExtensionPane.addData(TYPE_NAMES[STATE], TYPE_NAMES[STATE], true); } }); JMenuItem menu = new JMenuItem(TYPE_NAMES[USER]); popupMenu.add(menu); menu.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { groupExtensionPane.addData(TYPE_NAMES[USER], TYPE_NAMES[USER], true); } }); } private void doEdit(ChangeEvent e) { MouseEvent event = (MouseEvent) e.getSource(); JPopupMenu editPopMenu = new JPopupMenu(); final String oldName = Utils.objectToString(groupExtensionPane.getSelectedObject()); editPopMenu.add(createAreaItem(oldName)); editPopMenu.add(createMarkerItem(oldName)); editPopMenu.add(createLayerItem(oldName)); editPopMenu.add(createRenameItem()); editPopMenu.show(MapGroupExtensionPane.this, event.getXOnScreen() - OFFSET_X, event.getYOnScreen() - OFFSET_Y); } private void mapCheckBeforeEdit(String name){ if(MapSvgXMLHelper.getInstance().containsMapName(name) || MapSvgXMLHelper.getInstance().getNewMapAttr(name)!=null){ return; } MapSvgAttr attr = new MapSvgAttr(); attr.setFilePath(MapSvgXMLHelper.customMapPath() + CoreConstants.SEPARATOR + name + ".svg"); MapSvgXMLHelper.getInstance().addNewSvgMaps(name,attr); } private JMenuItem createAreaItem(final String oldName) { JMenuItem editFileItem = new JMenuItem(Inter.getLocText(new String[]{"Edit", "Image", "Filed"})); editFileItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { final MapCustomPane image = new MapCustomPane(); image.setImageSelectType(MapShapeValue.AREA); image.populateBean(oldName); image.setTypeNameAndMapName(groupExtensionPane.getSelectedType(), Utils.objectToString(groupExtensionPane.getSelectedObject())); mapCheckBeforeEdit(oldName); final Image oldImage = getMapImage(oldName); BasicDialog dialog = image.showMediumWindow(SwingUtilities.getWindowAncestor(MapGroupExtensionPane.this), new DialogActionAdapter() { public void doOk() { image.updateBean(); // 比较两个前后的名字是否相同, 是图片 如果图片不同, 则直接比较 Image newImage = getMapImage(oldName); if(!ComparatorUtils.equals(oldImage, newImage)) { fireStateChange(); } //versionID递增 MapSvgAttr old = MapSvgXMLHelper.getInstance().getMapAttr(oldName); if(old != null) { old.addVersionID(); } saveMapInfo(oldName); refresh(); } }); dialog.setVisible(true); } }); return editFileItem; } //根据地图的名字返回地图的图片 private Image getMapImage(String mapName) { if (MapSvgXMLHelper.getInstance().containsMapName(mapName)) { MapSvgAttr mapAttr = MapSvgXMLHelper.getInstance().getMapAttr(mapName); if(mapAttr == null) { return null; } return mapAttr.getMapImage(); } return null; } private JMenuItem createMarkerItem(final String oldName) { JMenuItem editMarkerItem = new JMenuItem(Inter.getLocText(new String[]{"Edit", "Image", "Marker"})); editMarkerItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { final MapCustomPane image = new MapCustomPane(); image.setImageSelectType(MapShapeValue.POINT); image.populateBean(oldName); mapCheckBeforeEdit(oldName); final Image oldImage = getMapImage(oldName); BasicDialog dialog = image.showMediumWindow(SwingUtilities.getWindowAncestor(image), new DialogActionAdapter() { public void doOk() { image.updateBean(); Image newImage = getMapImage(oldName); if(!ComparatorUtils.equals(oldImage, newImage)) { fireStateChange(); } //versionID递增 MapSvgAttr old = MapSvgXMLHelper.getInstance().getMapAttr(oldName); if(old != null) { old.addVersionID(); } saveMapInfo(oldName); refresh(); } }); dialog.setVisible(true); } }); return editMarkerItem; } private JMenuItem createLayerItem(final String oldName) { JMenuItem corrItem = new JMenuItem(Inter.getLocText(new String[]{"Filed", "Corresponding_Fields"})); corrItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { final MapDefiAreaNamePane namedPane = new MapDefiAreaNamePane(); namedPane.populateBean(oldName); mapCheckBeforeEdit(oldName); BasicDialog dialog = namedPane.showMediumWindow(SwingUtilities.getWindowAncestor(namedPane), new DialogActionAdapter() { public void doOk() { namedPane.updateBean();// 地图的名称 value对应情况 MapSvgAttr old = MapSvgXMLHelper.getInstance().getMapAttr(oldName); if(old != null) { old.addVersionID(); } saveMapInfo(oldName); } }); dialog.setVisible(true); refresh(); } }); return corrItem; } private void showRenameWaring(String newName){ JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), "\"" + newName + "\"" + Inter.getLocText("Utils-has_been_existed") + "!", Inter.getLocText("FR-Designer_Alert"), JOptionPane.WARNING_MESSAGE); } private JMenuItem createRenameItem() { JMenuItem renameItem = new JMenuItem(Inter.getLocText("FR-Chart-Map_Rename")); renameItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String newName = JOptionPane.showInputDialog(DesignerContext.getDesignerFrame().getContentPane(), Inter.getLocText("FR-Chart-Map_Rename"), groupExtensionPane.getSelectedObject()); if (StringUtils.isNotBlank(newName)) { String oldName = Utils.objectToString(groupExtensionPane.getSelectedObject()); if(ComparatorUtils.equals(oldName, newName)){ return; } //本地在看看临时的helper里面有没有 if(MapSvgXMLHelper.getInstance().getNewMapAttr(newName) != null){ showRenameWaring(newName); return; } try{//提醒名字已存在 if(FRContext.getCurrentEnv().fileExists(StableUtils.pathJoin( new String[]{MapSvgXMLHelper.relativeDefaultMapPath(),newName+SvgProvider.EXTENSION}))){ showRenameWaring(newName); return; } if(FRContext.getCurrentEnv().fileExists(StableUtils.pathJoin( new String[]{MapSvgXMLHelper.relativeCustomMapPath(), newName + SvgProvider.EXTENSION}))){ showRenameWaring(newName); return; } MapSvgAttr editingAttr = MapSvgXMLHelper.getInstance().getMapAttr(oldName); if(editingAttr == null){ editingAttr = MapSvgXMLHelper.getInstance().getNewMapAttr(oldName); } if( editingAttr == null) { return; } editingAttr.renameMap(newName); groupExtensionPane.setValueAtCurrentSelectIndex(newName); fireStateChange(); saveMapInfo(newName); FRContext.getCurrentEnv().deleteFile( StableUtils.pathJoin(new String[]{MapSvgXMLHelper.relativeDefaultMapPath(),oldName+SvgProvider.EXTENSION})); FRContext.getCurrentEnv().deleteFile( StableUtils.pathJoin(new String[]{MapSvgXMLHelper.relativeCustomMapPath(),oldName+SvgProvider.EXTENSION})); refresh(); }catch (Exception exp){ FRLogger.getLogger().error(exp.getMessage()); } } } }); return renameItem; } private void refresh() { this.validate(); this.repaint(); DesignerFrame frame = DesignerContext.getDesignerFrame(); if(frame != null) { frame.repaint();//kunsnat: 图表属性没变, 只是读取时 内容变化. } } //保存修改过的地图信息 private void saveMapInfo(final String mapName) { SwingWorker worker = new SwingWorker() { @Override protected Integer doInBackground() throws Exception { MapSvgAttr attr = MapSvgXMLHelper.getInstance().getMapAttr(mapName);// 只有在编辑地图时才需要储存相关数据 @kuns if(attr != null){ attr.writeBack(mapName); } return 0; } @Override protected void done() { FRLogger.getLogger().info(Inter.getLocText("FR-Chart-Map_Saved")); // 地图已经保存. } }; worker.execute(); DesignerEnvManager.addWorkers(worker); } private void fireStateChange() { for (int i = changeListeners.size(); i > 0; i--) { changeListeners.get(i - 1).stateChanged(new javax.swing.event.ChangeEvent(this)); } } /** * 更新地图属性 * @return 返回地图名称. */ public String updateBean(MapPlot plot) { if(!hasPopulated){ this.populateBean(plot); hasPopulated = true; } MapHelper helper = plot.isSvgMap() ? MapSvgXMLHelper.getInstance() : MapXMLHelper.getInstance(); helper.clearCateNames(); for (String type : TYPE_NAMES) { Object[] datas = groupExtensionPane.getData(type); for (Object name : datas) { helper.addCateNames(type, name); } } return Utils.objectToString(groupExtensionPane.getSelectedObject()); } /** * 更新地图名称 * @param mapPlot 地图 */ public void populateBean(MapPlot mapPlot) { hasPopulated = false; groupExtensionPane.clearData(); for (String type : TYPE_NAMES) { MapHelper helper = mapPlot.isSvgMap() ? MapSvgXMLHelper.getInstance() : MapXMLHelper.getInstance(); java.util.List list = helper.getNamesListWithCateName(type); for (Object name : list) { groupExtensionPane.addData(name, type); } } groupExtensionPane.setSelectedObject(mapPlot.getMapName()); hasPopulated = true; } /** * 给组件登记一个观察者监听事件 * * @param listener 观察者监听事件 */ public void registerChangeListener(final UIObserverListener listener) { changeListeners.add(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent e) { listener.doChange(); } }); } /** * 组件是否需要响应添加的观察者事件 * * @return 如果需要响应观察者事件则返回true,否则返回false */ public boolean shouldResponseChangeListener() { return true; } public void setEnabled(boolean isEnabled){ super.setEnabled(isEnabled); addButton.setEnabled(isEnabled); popupMenu.setEnabled(isEnabled); groupExtensionPane.setEnabled(isEnabled); } } \ No newline at end of file diff --git a/designer_chart/src/com/fr/design/chart/series/PlotSeries/MapImageEditPane.java b/designer_chart/src/com/fr/design/chart/series/PlotSeries/MapImageEditPane.java index 6f9c15c55..4aff10c37 100644 --- a/designer_chart/src/com/fr/design/chart/series/PlotSeries/MapImageEditPane.java +++ b/designer_chart/src/com/fr/design/chart/series/PlotSeries/MapImageEditPane.java @@ -1,34 +1,13 @@ package com.fr.design.chart.series.PlotSeries; -import java.awt.AlphaComposite; -import java.awt.BasicStroke; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Image; -import java.awt.Point; -import java.awt.Rectangle; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.awt.event.MouseMotionListener; -import java.awt.geom.GeneralPath; -import java.util.*; - -import javax.swing.BoxLayout; -import javax.swing.DefaultListModel; -import javax.swing.JComponent; -import javax.swing.JList; -import javax.swing.JPanel; -import javax.swing.SwingUtilities; - -import com.fr.base.*; -import com.fr.chart.base.MapSvgAttr; -import com.fr.chart.base.MapSvgXMLHelper; +import com.fr.base.BaseUtils; +import com.fr.base.MapSvgAttr; +import com.fr.base.MapSvgXMLHelper; +import com.fr.base.Utils; import com.fr.chart.chartglyph.MapShapeValue; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.dialog.UIDialog; import com.fr.design.event.ChangeEvent; import com.fr.design.event.ChangeListener; import com.fr.design.gui.icontainer.UIScrollPane; @@ -37,13 +16,23 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itable.UISelectTable; import com.fr.design.gui.itable.UITableNoOptionUI; import com.fr.design.gui.itextfield.UITextField; -import com.fr.design.dialog.DialogActionAdapter; -import com.fr.design.dialog.UIDialog; +import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.ComparatorUtils; import com.fr.general.Inter; import com.fr.stable.CoreGraphHelper; import com.fr.stable.StringUtils; -import com.fr.design.utils.gui.GUICoreUtils; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.event.MouseMotionListener; +import java.awt.geom.GeneralPath; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; /** * 地图 图片编辑界面 选中图片 编辑. 支持鼠标选中等事件 diff --git a/designer_chart/src/com/fr/design/chart/series/PlotSeries/UIGroupExtensionPane.java b/designer_chart/src/com/fr/design/chart/series/PlotSeries/UIGroupExtensionPane.java index 2ad670341..1e26f37b0 100644 --- a/designer_chart/src/com/fr/design/chart/series/PlotSeries/UIGroupExtensionPane.java +++ b/designer_chart/src/com/fr/design/chart/series/PlotSeries/UIGroupExtensionPane.java @@ -1 +1 @@ -package com.fr.design.chart.series.PlotSeries; import com.fr.chart.base.MapSvgXMLHelper; import com.fr.design.constants.LayoutConstants; import com.fr.design.constants.UIConstants; import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.UIDialog; import com.fr.design.event.ChangeEvent; import com.fr.design.event.ChangeListener; import com.fr.design.gui.frpane.UIExtensionPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.BoldFontTextLabel; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextfield.UISearchTextField; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.DesignerContext; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.ComparatorUtils; import com.fr.general.FRLogger; import com.fr.general.GeneralUtils; import com.fr.general.Inter; import com.fr.stable.ArrayUtils; import javax.swing.*; import javax.swing.border.Border; import javax.swing.event.*; import java.awt.*; import java.awt.event.*; import java.util.ArrayList; import java.util.List; /** * Created by IntelliJ IDEA. * Author : Richer * Version: 7.0.3 * Date: 12-12-29 * Time: 上午11:14 * 可收缩的面板,只有两层 */ public class UIGroupExtensionPane extends BasicPane { public static final String EDIT = "edit"; public static final String DELETE = "delete"; private static final int BUTTONWIDTH = 16; private static final int DIALOG_WIDTH = 140; private static final int DIALOG_HEIGHT = 100; private UISearchTextField searchTextFiled; private JList[] contentViews; private Component[][] components; private String[] titles; private java.util.List selectionListeners = new ArrayList(); private java.util.List editListeners = new ArrayList(); private List deleteListeners = new ArrayList(); private boolean isPressOnDelete = false; // 是否点击在删除按钮上 @Override protected String title4PopupWindow() { return "group"; } public UIGroupExtensionPane(String[] titles) { this.titles = titles; if (ArrayUtils.isEmpty(titles)) { return; } initComponents(titles); } private void initComponents(String[] titles) { setBackground(null); searchTextFiled = initSearchTextField(); int count = titles.length; contentViews = new JList[count]; components = new Component[count + 1][]; double p = TableLayout.PREFERRED; double f = TableLayout.FILL; double[] rowSize = new double[count + 1]; double[] columnSize = {f}; for (int i = 0; i < count + 1; i++) { rowSize[i] = p; if (i == 0) { components[i] = new Component[]{searchTextFiled}; } else if (i > 0 && i < count + 1) { JList li = new JList(new DefaultListModel()); li.addListSelectionListener(listSelectionListener); li.addMouseListener(mouseListener); li.setCellRenderer(listCellRenderer); li.setBackground(null); contentViews[i - 1] = li; components[i] = new UIExtensionPane[]{new UIExtensionPane(titles[i - 1], li, false)}; } } JPanel centerPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 0, 0); setLayout(new BorderLayout()); add(new UIScrollPane(centerPane), BorderLayout.CENTER); } private UISearchTextField initSearchTextField() { UISearchTextField searchTextFiled = new UISearchTextField() { public Dimension getPreferredSize() { return new Dimension(120, 22); } }; searchTextFiled.setIconPosition(SwingConstants.RIGHT); searchTextFiled.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { doFilter(); } @Override public void removeUpdate(DocumentEvent e) { doFilter(); } @Override public void changedUpdate(DocumentEvent e) { doFilter(); } }); return searchTextFiled; } /** * 返回index列表的数据 */ public Object[] getData(int index) { if (index < 0 || index > contentViews.length) { return ArrayUtils.EMPTY_OBJECT_ARRAY; } ListModel model = contentViews[index].getModel(); Object[] items = new Object[model.getSize()]; for (int i = 0, len = model.getSize(); i < len; i++) { items[i] = model.getElementAt(i); } return items; } /** * 返回对应Title的列表数组 */ public Object[] getData(String title) { int dataIndex = ArrayUtils.indexOf(titles, title); if (dataIndex != ArrayUtils.INDEX_NOT_FOUND) { return getData(dataIndex); } return ArrayUtils.EMPTY_OBJECT_ARRAY; } private void doFilter() { for (JList list : contentViews) { ListDataListener[] ls = ((DefaultListModel) list.getModel()).getListDataListeners(); for (ListDataListener l : ls) { l.contentsChanged(new ListDataEvent(l, ListDataEvent.CONTENTS_CHANGED, 0, list.getModel().getSize())); } } for (int i = 1, len = components.length; i < len; i++) { ((UIExtensionPane) components[i][0]).setExpand(true); } } /** * 获取选中的值 * * @return 选中的值 */ public Object getSelectedObject() { for (JList list : contentViews) { if (list.getSelectedValue() != null) { return list.getSelectedValue(); } } return null; } /** * 返回选中的类别 * @return 类别 */ public String getSelectedType(){ for (int i = 0, len = contentViews.length; i < len; i++) { if(contentViews[i].getSelectedValue() != null){ return titles[i]; } } return ""; } /** * 设置选中的数据 */ public void setSelectedObject(Object value) { for (int i = 0, len = contentViews.length; i < len; i++) { UIExtensionPane extensionPane = (UIExtensionPane) components[i + 1][0]; JList list = contentViews[i]; DefaultListModel model = (DefaultListModel) list.getModel(); extensionPane.setExpand(model.contains(value)); if (model.contains(value)) { list.setSelectedValue(value, true); } } } /** * 设置数据选中的序号. */ public void setValueAtCurrentSelectIndex(Object value) { for (JList list : contentViews) { if (list.getSelectedIndex() != -1) { ((DefaultListModel) list.getModel()).setElementAt(value, list.getSelectedIndex()); } } } /** * 根据索引来添加数据 * * @param data 要添加的数据 * @param index 要添加的数据向的索引 */ public void addData(Object data, int index) { addData(data, index, false); } /** * 根据索引来添加数据 * * @param data 要添加的数据 * @param index 要添加的数据向的索引 * @param checkRepeat 是否检查名字重复 */ public void addData(Object data, int index, boolean checkRepeat) { if (contentViews == null || index < 0 || index > contentViews.length - 1) { return; } JList list = contentViews[index]; DefaultListModel model = (DefaultListModel) list.getModel(); if (data instanceof String) { model.addElement(createUnrepeatedName(model, (String) data, checkRepeat)); } if (checkRepeat) { // 将添加类型以外的其他类型都收起来 for (int i = 1, len = components.length; i < len; i++) { ((UIExtensionPane) components[i][0]).setExpand(false); } ((UIExtensionPane) components[index + 1][0]).setExpand(true); int selectedIndex = list.getModel().getSize() - 1; list.setSelectedIndex(selectedIndex); dealNewAddedDataIndex(((DefaultListModel) list.getModel()).elementAt(selectedIndex)); } } /** * 新添加的数据的序号 * @param data 数据 */ protected void dealNewAddedDataIndex(Object data){ } /** * 根据标题来添加数据 * * @param data 要添加的数据 * @param title 要添加数据的项的标题文字 */ public void addData(Object data, String title) { addData(data, title, false); } /** * 根据标题来添加数据 * * @param data 要添加的数据 * @param title 要添加数据的项的标题文字 * @param checkRepeat 是否检查名字重复 */ public void addData(Object data, String title, boolean checkRepeat) { int addIndex = ArrayUtils.indexOf(titles, title); if (addIndex != ArrayUtils.INDEX_NOT_FOUND) { addData(data, addIndex, checkRepeat); } } /** * 清除所有的数据 */ public void clearData() { for (JList list : contentViews) { ((DefaultListModel) list.getModel()).clear(); } } private String createUnrepeatedName(DefaultListModel model, String name, boolean checkRepeat) { if (!checkRepeat) { return name; } int count = model.getSize(); int extra = 1; String newName = name + (count + extra); boolean hasRepeated = false; do { hasRepeated = false; newName = name + (count + extra); for (int i = 0; i < count; i++) { if (ComparatorUtils.equals(model.getElementAt(i), newName)) { hasRepeated = true; extra++; } } } while (hasRepeated); return name + (count + extra); } /** * 判断该控件是否应该有编辑操作 * * @param list 列表组件 * @return 如果有编辑操作则需要显示相应的图标 */ private boolean hasEditOperation(JList list) { return true; } private DefaultListCellRenderer listCellRenderer = new DefaultListCellRenderer() { public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { JComponent c = (JComponent) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (!hasEditOperation(list)) { return c; } Border border = null; c.setBorder(border); UILabel editLabel = new UILabel(UIConstants.EDIT_ICON); UILabel deleteLabel = new UILabel(UIConstants.DELETE_ICON); JPanel editPane = GUICoreUtils.createFlowPane(new Component[]{editLabel, deleteLabel}, FlowLayout.LEFT, LayoutConstants.HGAP_LARGE); editPane.setBackground(isSelected ? c.getBackground() : null); editPane.setBorder(border); JPanel renderPane = GUICoreUtils.createBorderLayoutPane(c, BorderLayout.CENTER, editPane, BorderLayout.EAST); if (shouldFilter(value)) { renderPane.setPreferredSize(new Dimension(0, 0)); } return renderPane; } }; //事件发生的顺序是ListSelection、MousePressed、ListSelection、MouseReleased private ListSelectionListener listSelectionListener = new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { //在鼠标按下的时候的值改变事件,重置属性 if(e.getValueIsAdjusting()){ isPressOnDelete = false; } if(!isRespondToValueChange(e)){ return; } fireSelectionChangeListener(new ChangeEvent(e.getSource())); if (((JList) e.getSource()).getSelectedIndex() == -1) { return; } for (JList list : contentViews) { if (list.getSelectedIndex() != -1 && !ComparatorUtils.equals(list, e.getSource())) { try { list.setSelectedIndices(null); } catch (Exception ee) { } } } } }; /** * 是否响应list值改变 * @return 响应 */ protected boolean isRespondToValueChange(ListSelectionEvent e){ return true; } private boolean shouldFilter(Object value) { return !GeneralUtils.objectToString(value).toLowerCase().contains(searchTextFiled.getText().toLowerCase()); } private MouseListener mouseListener = new MouseAdapter() { /** * {@inheritDoc} */ @Override public void mousePressed(final MouseEvent e) { isPressOnDelete = false; final JList list = (JList) e.getSource(); Point point = e.getPoint(); final int index = list.locationToIndex(point); int width = list.getWidth(); if (hasEditOperation(list)) { // 删除按钮 if (point.x > width - (BUTTONWIDTH + LayoutConstants.HGAP_LARGE)) { BasicPane bp = new BasicPane() { protected String title4PopupWindow() { return ""; } }; isPressOnDelete = true; bp.setLayout(new BorderLayout()); bp.add(new BoldFontTextLabel(Inter.getLocText(new String[]{"Delete", "Chart-Map"}) + "?", SwingConstants.CENTER)); clearLastListSelection(list); final String selectedType = UIGroupExtensionPane.this.getSelectedType(); UIDialog dialog = bp.showUnsizedWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { public void doOk() { Object name = getSelectedObject(); ((DefaultListModel) list.getModel()).removeElementAt(index); MapSvgXMLHelper.getInstance().removeMapAttr(GeneralUtils.objectToString(name)); MapSvgXMLHelper.getInstance().removeCateNames(selectedType,GeneralUtils.objectToString(name)); fireDeleteListener(new ChangeEvent(e)); } }); dialog.setResizable(true); dialog.setSize(DIALOG_WIDTH, DIALOG_HEIGHT); dialog.setResizable(false); GUICoreUtils.centerWindow(dialog); dialog.setVisible(true); } // 编辑按钮 else if (point.x > width - (BUTTONWIDTH * 2 + 2 * LayoutConstants.HGAP_LARGE) && point.x < width - (BUTTONWIDTH + LayoutConstants.HGAP_LARGE)) { fireItemEditListener(new ChangeEvent(e)); } } } public void mouseReleased(MouseEvent e) { isPressOnDelete = false; } }; /** * 直接跨list点击删除按钮,要置之前list的选中项为空(因为删除操作不触发更新) * @param currentList 当前选中的list */ public void clearLastListSelection (JList currentList) { for (JList list : contentViews) { if (list.getSelectedIndex() != -1 && !ComparatorUtils.equals(list, currentList)) { try { list.setSelectedIndices(null); } catch (Exception e) { FRLogger.getLogger().error(e.getMessage()); } } } } /** * 是否点击在删除按钮上 * @return 是则返回true */ public boolean isPressOnDelete(){ return isPressOnDelete; } /** * 添加选中变化监听事件 * @param listener 监听 */ public void addSelectionChangeListener(ChangeListener listener) { selectionListeners.add(listener); } private void fireSelectionChangeListener(ChangeEvent e) { for (int i = selectionListeners.size(); i > 0; i--) { selectionListeners.get(i - 1).fireChanged(e); } } /** * 添加Item的监听事件 * @param listener 监听器 */ public void addItemEditListener(ChangeListener listener) { editListeners.add(listener); } private void fireItemEditListener(ChangeEvent e) { for (int i = editListeners.size(); i > 0; i--) { editListeners.get(i - 1).fireChanged(e); } } /** * 添加删除事件的监听事件 * @param listener 监听 */ public void addDeleteListener(ChangeListener listener) { deleteListeners.add(listener); } private void fireDeleteListener(ChangeEvent e) { for(int i = deleteListeners.size(); i > 0; i--) { deleteListeners.get(i - 1).fireChanged(e); } } public void setEnabled(boolean isEnabled){ super.setEnabled(isEnabled); if(searchTextFiled != null){ searchTextFiled.setEnabled(isEnabled); } if(this.components != null){ for(int i = 0; i < this.components.length; i++){ Component[] comp = this.components[i]; for(int j = 0; j < comp.length; j++){ comp[j].setEnabled(isEnabled); } } } } /** * 测试程序 * @param args 参数 */ public static void main(String[] args) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container c = f.getContentPane(); c.setBackground(Color.WHITE); c.setLayout(new BoxLayout(c, BoxLayout.Y_AXIS)); final UIGroupExtensionPane g = new UIGroupExtensionPane(new String[]{"title1", "title2", "title3"}); c.add(g, BorderLayout.CENTER); JPanel pp = new JPanel(new FlowLayout()); c.add(pp, BorderLayout.SOUTH); UIButton test = new UIButton("add1"); test.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { g.addData("test111", 0); } }); pp.add(test); UIButton test2 = new UIButton("add2"); test2.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { g.addData("test222", 1); } }); pp.add(test2); f.setSize(360, 500); f.setLocation(200, 100); f.setVisible(true); } } \ No newline at end of file +package com.fr.design.chart.series.PlotSeries; import com.fr.base.MapSvgXMLHelper; import com.fr.design.constants.LayoutConstants; import com.fr.design.constants.UIConstants; import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.UIDialog; import com.fr.design.event.ChangeEvent; import com.fr.design.event.ChangeListener; import com.fr.design.gui.frpane.UIExtensionPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.BoldFontTextLabel; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextfield.UISearchTextField; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.DesignerContext; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.ComparatorUtils; import com.fr.general.FRLogger; import com.fr.general.GeneralUtils; import com.fr.general.Inter; import com.fr.stable.ArrayUtils; import javax.swing.*; import javax.swing.border.Border; import javax.swing.event.*; import java.awt.*; import java.awt.event.*; import java.util.ArrayList; import java.util.List; /** * Created by IntelliJ IDEA. * Author : Richer * Version: 7.0.3 * Date: 12-12-29 * Time: 上午11:14 * 可收缩的面板,只有两层 */ public class UIGroupExtensionPane extends BasicPane { public static final String EDIT = "edit"; public static final String DELETE = "delete"; private static final int BUTTONWIDTH = 16; private static final int DIALOG_WIDTH = 140; private static final int DIALOG_HEIGHT = 100; private UISearchTextField searchTextFiled; private JList[] contentViews; private Component[][] components; private String[] titles; private java.util.List selectionListeners = new ArrayList(); private java.util.List editListeners = new ArrayList(); private List deleteListeners = new ArrayList(); private boolean isPressOnDelete = false; // 是否点击在删除按钮上 @Override protected String title4PopupWindow() { return "group"; } public UIGroupExtensionPane(String[] titles) { this.titles = titles; if (ArrayUtils.isEmpty(titles)) { return; } initComponents(titles); } private void initComponents(String[] titles) { setBackground(null); searchTextFiled = initSearchTextField(); int count = titles.length; contentViews = new JList[count]; components = new Component[count + 1][]; double p = TableLayout.PREFERRED; double f = TableLayout.FILL; double[] rowSize = new double[count + 1]; double[] columnSize = {f}; for (int i = 0; i < count + 1; i++) { rowSize[i] = p; if (i == 0) { components[i] = new Component[]{searchTextFiled}; } else if (i > 0 && i < count + 1) { JList li = new JList(new DefaultListModel()); li.addListSelectionListener(listSelectionListener); li.addMouseListener(mouseListener); li.setCellRenderer(listCellRenderer); li.setBackground(null); contentViews[i - 1] = li; components[i] = new UIExtensionPane[]{new UIExtensionPane(titles[i - 1], li, false)}; } } JPanel centerPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 0, 0); setLayout(new BorderLayout()); add(new UIScrollPane(centerPane), BorderLayout.CENTER); } private UISearchTextField initSearchTextField() { UISearchTextField searchTextFiled = new UISearchTextField() { public Dimension getPreferredSize() { return new Dimension(120, 22); } }; searchTextFiled.setIconPosition(SwingConstants.RIGHT); searchTextFiled.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { doFilter(); } @Override public void removeUpdate(DocumentEvent e) { doFilter(); } @Override public void changedUpdate(DocumentEvent e) { doFilter(); } }); return searchTextFiled; } /** * 返回index列表的数据 */ public Object[] getData(int index) { if (index < 0 || index > contentViews.length) { return ArrayUtils.EMPTY_OBJECT_ARRAY; } ListModel model = contentViews[index].getModel(); Object[] items = new Object[model.getSize()]; for (int i = 0, len = model.getSize(); i < len; i++) { items[i] = model.getElementAt(i); } return items; } /** * 返回对应Title的列表数组 */ public Object[] getData(String title) { int dataIndex = ArrayUtils.indexOf(titles, title); if (dataIndex != ArrayUtils.INDEX_NOT_FOUND) { return getData(dataIndex); } return ArrayUtils.EMPTY_OBJECT_ARRAY; } private void doFilter() { for (JList list : contentViews) { ListDataListener[] ls = ((DefaultListModel) list.getModel()).getListDataListeners(); for (ListDataListener l : ls) { l.contentsChanged(new ListDataEvent(l, ListDataEvent.CONTENTS_CHANGED, 0, list.getModel().getSize())); } } for (int i = 1, len = components.length; i < len; i++) { ((UIExtensionPane) components[i][0]).setExpand(true); } } /** * 获取选中的值 * * @return 选中的值 */ public Object getSelectedObject() { for (JList list : contentViews) { if (list.getSelectedValue() != null) { return list.getSelectedValue(); } } return null; } /** * 返回选中的类别 * @return 类别 */ public String getSelectedType(){ for (int i = 0, len = contentViews.length; i < len; i++) { if(contentViews[i].getSelectedValue() != null){ return titles[i]; } } return ""; } /** * 设置选中的数据 */ public void setSelectedObject(Object value) { for (int i = 0, len = contentViews.length; i < len; i++) { UIExtensionPane extensionPane = (UIExtensionPane) components[i + 1][0]; JList list = contentViews[i]; DefaultListModel model = (DefaultListModel) list.getModel(); extensionPane.setExpand(model.contains(value)); if (model.contains(value)) { list.setSelectedValue(value, true); } } } /** * 设置数据选中的序号. */ public void setValueAtCurrentSelectIndex(Object value) { for (JList list : contentViews) { if (list.getSelectedIndex() != -1) { ((DefaultListModel) list.getModel()).setElementAt(value, list.getSelectedIndex()); } } } /** * 根据索引来添加数据 * * @param data 要添加的数据 * @param index 要添加的数据向的索引 */ public void addData(Object data, int index) { addData(data, index, false); } /** * 根据索引来添加数据 * * @param data 要添加的数据 * @param index 要添加的数据向的索引 * @param checkRepeat 是否检查名字重复 */ public void addData(Object data, int index, boolean checkRepeat) { if (contentViews == null || index < 0 || index > contentViews.length - 1) { return; } JList list = contentViews[index]; DefaultListModel model = (DefaultListModel) list.getModel(); if (data instanceof String) { model.addElement(createUnrepeatedName(model, (String) data, checkRepeat)); } if (checkRepeat) { // 将添加类型以外的其他类型都收起来 for (int i = 1, len = components.length; i < len; i++) { ((UIExtensionPane) components[i][0]).setExpand(false); } ((UIExtensionPane) components[index + 1][0]).setExpand(true); int selectedIndex = list.getModel().getSize() - 1; list.setSelectedIndex(selectedIndex); dealNewAddedDataIndex(((DefaultListModel) list.getModel()).elementAt(selectedIndex)); } } /** * 新添加的数据的序号 * @param data 数据 */ protected void dealNewAddedDataIndex(Object data){ } /** * 根据标题来添加数据 * * @param data 要添加的数据 * @param title 要添加数据的项的标题文字 */ public void addData(Object data, String title) { addData(data, title, false); } /** * 根据标题来添加数据 * * @param data 要添加的数据 * @param title 要添加数据的项的标题文字 * @param checkRepeat 是否检查名字重复 */ public void addData(Object data, String title, boolean checkRepeat) { int addIndex = ArrayUtils.indexOf(titles, title); if (addIndex != ArrayUtils.INDEX_NOT_FOUND) { addData(data, addIndex, checkRepeat); } } /** * 清除所有的数据 */ public void clearData() { for (JList list : contentViews) { ((DefaultListModel) list.getModel()).clear(); } } private String createUnrepeatedName(DefaultListModel model, String name, boolean checkRepeat) { if (!checkRepeat) { return name; } int count = model.getSize(); int extra = 1; String newName = name + (count + extra); boolean hasRepeated = false; do { hasRepeated = false; newName = name + (count + extra); for (int i = 0; i < count; i++) { if (ComparatorUtils.equals(model.getElementAt(i), newName)) { hasRepeated = true; extra++; } } } while (hasRepeated); return name + (count + extra); } /** * 判断该控件是否应该有编辑操作 * * @param list 列表组件 * @return 如果有编辑操作则需要显示相应的图标 */ private boolean hasEditOperation(JList list) { return true; } private DefaultListCellRenderer listCellRenderer = new DefaultListCellRenderer() { public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { JComponent c = (JComponent) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (!hasEditOperation(list)) { return c; } Border border = null; c.setBorder(border); UILabel editLabel = new UILabel(UIConstants.EDIT_ICON); UILabel deleteLabel = new UILabel(UIConstants.DELETE_ICON); JPanel editPane = GUICoreUtils.createFlowPane(new Component[]{editLabel, deleteLabel}, FlowLayout.LEFT, LayoutConstants.HGAP_LARGE); editPane.setBackground(isSelected ? c.getBackground() : null); editPane.setBorder(border); JPanel renderPane = GUICoreUtils.createBorderLayoutPane(c, BorderLayout.CENTER, editPane, BorderLayout.EAST); if (shouldFilter(value)) { renderPane.setPreferredSize(new Dimension(0, 0)); } return renderPane; } }; //事件发生的顺序是ListSelection、MousePressed、ListSelection、MouseReleased private ListSelectionListener listSelectionListener = new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { //在鼠标按下的时候的值改变事件,重置属性 if(e.getValueIsAdjusting()){ isPressOnDelete = false; } if(!isRespondToValueChange(e)){ return; } fireSelectionChangeListener(new ChangeEvent(e.getSource())); if (((JList) e.getSource()).getSelectedIndex() == -1) { return; } for (JList list : contentViews) { if (list.getSelectedIndex() != -1 && !ComparatorUtils.equals(list, e.getSource())) { try { list.setSelectedIndices(null); } catch (Exception ee) { } } } } }; /** * 是否响应list值改变 * @return 响应 */ protected boolean isRespondToValueChange(ListSelectionEvent e){ return true; } private boolean shouldFilter(Object value) { return !GeneralUtils.objectToString(value).toLowerCase().contains(searchTextFiled.getText().toLowerCase()); } private MouseListener mouseListener = new MouseAdapter() { /** * {@inheritDoc} */ @Override public void mousePressed(final MouseEvent e) { isPressOnDelete = false; final JList list = (JList) e.getSource(); Point point = e.getPoint(); final int index = list.locationToIndex(point); int width = list.getWidth(); if (hasEditOperation(list)) { // 删除按钮 if (point.x > width - (BUTTONWIDTH + LayoutConstants.HGAP_LARGE)) { BasicPane bp = new BasicPane() { protected String title4PopupWindow() { return ""; } }; isPressOnDelete = true; bp.setLayout(new BorderLayout()); bp.add(new BoldFontTextLabel(Inter.getLocText(new String[]{"Delete", "Chart-Map"}) + "?", SwingConstants.CENTER)); clearLastListSelection(list); final String selectedType = UIGroupExtensionPane.this.getSelectedType(); UIDialog dialog = bp.showUnsizedWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { public void doOk() { Object name = getSelectedObject(); ((DefaultListModel) list.getModel()).removeElementAt(index); MapSvgXMLHelper.getInstance().removeMapAttr(GeneralUtils.objectToString(name)); MapSvgXMLHelper.getInstance().removeCateNames(selectedType,GeneralUtils.objectToString(name)); fireDeleteListener(new ChangeEvent(e)); } }); dialog.setResizable(true); dialog.setSize(DIALOG_WIDTH, DIALOG_HEIGHT); dialog.setResizable(false); GUICoreUtils.centerWindow(dialog); dialog.setVisible(true); } // 编辑按钮 else if (point.x > width - (BUTTONWIDTH * 2 + 2 * LayoutConstants.HGAP_LARGE) && point.x < width - (BUTTONWIDTH + LayoutConstants.HGAP_LARGE)) { fireItemEditListener(new ChangeEvent(e)); } } } public void mouseReleased(MouseEvent e) { isPressOnDelete = false; } }; /** * 直接跨list点击删除按钮,要置之前list的选中项为空(因为删除操作不触发更新) * @param currentList 当前选中的list */ public void clearLastListSelection (JList currentList) { for (JList list : contentViews) { if (list.getSelectedIndex() != -1 && !ComparatorUtils.equals(list, currentList)) { try { list.setSelectedIndices(null); } catch (Exception e) { FRLogger.getLogger().error(e.getMessage()); } } } } /** * 是否点击在删除按钮上 * @return 是则返回true */ public boolean isPressOnDelete(){ return isPressOnDelete; } /** * 添加选中变化监听事件 * @param listener 监听 */ public void addSelectionChangeListener(ChangeListener listener) { selectionListeners.add(listener); } private void fireSelectionChangeListener(ChangeEvent e) { for (int i = selectionListeners.size(); i > 0; i--) { selectionListeners.get(i - 1).fireChanged(e); } } /** * 添加Item的监听事件 * @param listener 监听器 */ public void addItemEditListener(ChangeListener listener) { editListeners.add(listener); } private void fireItemEditListener(ChangeEvent e) { for (int i = editListeners.size(); i > 0; i--) { editListeners.get(i - 1).fireChanged(e); } } /** * 添加删除事件的监听事件 * @param listener 监听 */ public void addDeleteListener(ChangeListener listener) { deleteListeners.add(listener); } private void fireDeleteListener(ChangeEvent e) { for(int i = deleteListeners.size(); i > 0; i--) { deleteListeners.get(i - 1).fireChanged(e); } } public void setEnabled(boolean isEnabled){ super.setEnabled(isEnabled); if(searchTextFiled != null){ searchTextFiled.setEnabled(isEnabled); } if(this.components != null){ for(int i = 0; i < this.components.length; i++){ Component[] comp = this.components[i]; for(int j = 0; j < comp.length; j++){ comp[j].setEnabled(isEnabled); } } } } /** * 测试程序 * @param args 参数 */ public static void main(String[] args) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container c = f.getContentPane(); c.setBackground(Color.WHITE); c.setLayout(new BoxLayout(c, BoxLayout.Y_AXIS)); final UIGroupExtensionPane g = new UIGroupExtensionPane(new String[]{"title1", "title2", "title3"}); c.add(g, BorderLayout.CENTER); JPanel pp = new JPanel(new FlowLayout()); c.add(pp, BorderLayout.SOUTH); UIButton test = new UIButton("add1"); test.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { g.addData("test111", 0); } }); pp.add(test); UIButton test2 = new UIButton("add2"); test2.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { g.addData("test222", 1); } }); pp.add(test2); f.setSize(360, 500); f.setLocation(200, 100); f.setVisible(true); } } \ No newline at end of file diff --git a/designer_chart/src/com/fr/design/mainframe/MapEditPane.java b/designer_chart/src/com/fr/design/mainframe/MapEditPane.java index 4c137afb7..2950a4d1f 100644 --- a/designer_chart/src/com/fr/design/mainframe/MapEditPane.java +++ b/designer_chart/src/com/fr/design/mainframe/MapEditPane.java @@ -1,7 +1,7 @@ package com.fr.design.mainframe; -import com.fr.chart.base.MapSvgAttr; -import com.fr.chart.base.MapSvgXMLHelper; +import com.fr.base.MapSvgAttr; +import com.fr.base.MapSvgXMLHelper; import com.fr.chart.chartglyph.MapShapeValue; import com.fr.design.beans.BasicBeanPane; import com.fr.design.chart.series.PlotSeries.AbstrctMapAttrEditPane; From 7963ee591353d47e4afe85551ad8d4b912870382 Mon Sep 17 00:00:00 2001 From: mengao <283296419@qq.com> Date: Thu, 27 Jul 2017 10:50:21 +0800 Subject: [PATCH 21/50] =?UTF-8?q?=E8=BF=98=E5=8E=9F=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/design/chart/report/MapCubeLayerPane.java | 4 ++-- .../src/com/fr/design/chart/report/MapCubeSetDataPane.java | 2 +- .../chart/series/PlotSeries/AbstrctMapAttrEditPane.java | 2 +- .../com/fr/design/chart/series/PlotSeries/MapCustomPane.java | 2 +- .../design/chart/series/PlotSeries/MapDefiAreaNamePane.java | 4 ++-- .../design/chart/series/PlotSeries/MapGroupExtensionPane.java | 2 +- .../fr/design/chart/series/PlotSeries/MapImageEditPane.java | 4 ++-- .../design/chart/series/PlotSeries/UIGroupExtensionPane.java | 2 +- designer_chart/src/com/fr/design/mainframe/MapEditPane.java | 4 ++-- 9 files changed, 13 insertions(+), 13 deletions(-) diff --git a/designer_chart/src/com/fr/design/chart/report/MapCubeLayerPane.java b/designer_chart/src/com/fr/design/chart/report/MapCubeLayerPane.java index 5d54f7853..461fe220a 100644 --- a/designer_chart/src/com/fr/design/chart/report/MapCubeLayerPane.java +++ b/designer_chart/src/com/fr/design/chart/report/MapCubeLayerPane.java @@ -1,10 +1,10 @@ package com.fr.design.chart.report; -import com.fr.base.MapSvgAttr; -import com.fr.base.MapSvgXMLHelper; import com.fr.base.MapXMLHelper; import com.fr.base.Utils; import com.fr.chart.base.ChartConstants; +import com.fr.chart.base.MapSvgAttr; +import com.fr.chart.base.MapSvgXMLHelper; import com.fr.chart.chartglyph.MapAttr; import com.fr.design.DesignerEnvManager; import com.fr.design.beans.BasicBeanPane; diff --git a/designer_chart/src/com/fr/design/chart/report/MapCubeSetDataPane.java b/designer_chart/src/com/fr/design/chart/report/MapCubeSetDataPane.java index 3110e241b..4c175500e 100644 --- a/designer_chart/src/com/fr/design/chart/report/MapCubeSetDataPane.java +++ b/designer_chart/src/com/fr/design/chart/report/MapCubeSetDataPane.java @@ -1,7 +1,7 @@ package com.fr.design.chart.report; -import com.fr.base.MapSvgXMLHelper; import com.fr.base.MapXMLHelper; +import com.fr.chart.base.MapSvgXMLHelper; import com.fr.design.beans.BasicBeanPane; import com.fr.design.editor.ValueEditorPane; import com.fr.design.editor.ValueEditorPaneFactory; diff --git a/designer_chart/src/com/fr/design/chart/series/PlotSeries/AbstrctMapAttrEditPane.java b/designer_chart/src/com/fr/design/chart/series/PlotSeries/AbstrctMapAttrEditPane.java index 254dfaec1..d2d61909b 100644 --- a/designer_chart/src/com/fr/design/chart/series/PlotSeries/AbstrctMapAttrEditPane.java +++ b/designer_chart/src/com/fr/design/chart/series/PlotSeries/AbstrctMapAttrEditPane.java @@ -1,6 +1,6 @@ package com.fr.design.chart.series.PlotSeries; -import com.fr.base.MapSvgAttr; +import com.fr.chart.base.MapSvgAttr; /** * Created by IntelliJ IDEA. diff --git a/designer_chart/src/com/fr/design/chart/series/PlotSeries/MapCustomPane.java b/designer_chart/src/com/fr/design/chart/series/PlotSeries/MapCustomPane.java index 49fa97eee..d844631c0 100644 --- a/designer_chart/src/com/fr/design/chart/series/PlotSeries/MapCustomPane.java +++ b/designer_chart/src/com/fr/design/chart/series/PlotSeries/MapCustomPane.java @@ -1,9 +1,9 @@ package com.fr.design.chart.series.PlotSeries; import com.fr.base.FRContext; -import com.fr.base.MapSvgAttr; import com.fr.base.TableData; import com.fr.base.Utils; +import com.fr.chart.base.MapSvgAttr; import com.fr.data.impl.EmbeddedTableData; import com.fr.design.beans.BasicBeanPane; import com.fr.design.data.DesignTableDataManager; diff --git a/designer_chart/src/com/fr/design/chart/series/PlotSeries/MapDefiAreaNamePane.java b/designer_chart/src/com/fr/design/chart/series/PlotSeries/MapDefiAreaNamePane.java index 0a3928ae4..ca8d3a67d 100644 --- a/designer_chart/src/com/fr/design/chart/series/PlotSeries/MapDefiAreaNamePane.java +++ b/designer_chart/src/com/fr/design/chart/series/PlotSeries/MapDefiAreaNamePane.java @@ -1,8 +1,8 @@ package com.fr.design.chart.series.PlotSeries; -import com.fr.base.MapSvgAttr; -import com.fr.base.MapSvgXMLHelper; import com.fr.base.Utils; +import com.fr.chart.base.MapSvgAttr; +import com.fr.chart.base.MapSvgXMLHelper; import com.fr.design.beans.BasicBeanPane; import com.fr.design.data.tabledata.wrapper.TableDataWrapper; import com.fr.design.editor.ValueEditorPane; diff --git a/designer_chart/src/com/fr/design/chart/series/PlotSeries/MapGroupExtensionPane.java b/designer_chart/src/com/fr/design/chart/series/PlotSeries/MapGroupExtensionPane.java index 74a8e687f..36b0ec847 100644 --- a/designer_chart/src/com/fr/design/chart/series/PlotSeries/MapGroupExtensionPane.java +++ b/designer_chart/src/com/fr/design/chart/series/PlotSeries/MapGroupExtensionPane.java @@ -1 +1 @@ -package com.fr.design.chart.series.PlotSeries; import com.fr.base.*; import com.fr.chart.chartattr.MapPlot; import com.fr.chart.chartglyph.MapShapeValue; import com.fr.design.DesignerEnvManager; import com.fr.design.constants.UIConstants; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.event.ChangeEvent; import com.fr.design.event.ChangeListener; import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserverListener; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerFrame; import com.fr.general.ComparatorUtils; import com.fr.general.FRLogger; import com.fr.general.Inter; import com.fr.stable.CoreConstants; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.stable.SvgProvider; import javax.swing.*; import javax.swing.event.ListSelectionEvent; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseEvent; import java.awt.geom.RoundRectangle2D; import java.util.ArrayList; /** * Created by IntelliJ IDEA. * Author : Richer * Version: 7.0.3 * Date: 12-12-29 * Time: 下午2:41 */ public class MapGroupExtensionPane extends BasicPane implements UIObserver { private static final String[] TYPE_NAMES = new String[]{ Inter.getLocText("FR-Chart-World_Map"), Inter.getLocText("FR-Chart-State_Map"), Inter.getLocText("FR-Chart-Province_Map"), Inter.getLocText("FR-Chart-Custom_Map")}; private static final int WORD = 0; private static final int NATION = 1; private static final int STATE = 2; private static final int USER = 3; private static final int OFFSET_X = 800; private static final int OFFSET_Y = 200; private UIGroupExtensionPane groupExtensionPane; private UIButton addButton; private JPopupMenu popupMenu; private ArrayList changeListeners = new ArrayList(); private boolean hasPopulated = false; @Override protected String title4PopupWindow() { return "Map"; } public MapGroupExtensionPane() { setLayout(new BorderLayout()); groupExtensionPane = new UIGroupExtensionPane(TYPE_NAMES){ /** * 新添加的数据的序号 * @param data 数据 */ protected void dealNewAddedDataIndex(Object data){ String newName = (String)data; MapSvgXMLHelper helper = MapSvgXMLHelper.getInstance(); if(helper.getNewMapAttr(newName) != null){ return; } MapSvgAttr attr = new MapSvgAttr(); attr.setFilePath(MapSvgXMLHelper.customMapPath() + CoreConstants.SEPARATOR + newName + ".svg"); helper.addNewSvgMaps(attr.getName(), attr); } /** * 一次鼠标的点击会有两次事件响应(按下和释放)。前者的事件属性中getValueIsAdjusting()=true,后者是false。 * 是否响应list值改变 * @return 鼠标按下时不响应,先响应mousePress事件,在鼠标释放是再响应list值改编的事件,并且点击删除不触发更新,并且populate后触发更新 */ protected boolean isRespondToValueChange(ListSelectionEvent e){ return !e.getValueIsAdjusting() && !this.isPressOnDelete() && hasPopulated; } }; groupExtensionPane.addSelectionChangeListener(new ChangeListener() { @Override public void fireChanged(ChangeEvent event) { fireStateChange(); } }); groupExtensionPane.addItemEditListener(new ChangeListener() { @Override public void fireChanged(ChangeEvent event) { doEdit(event); } }); groupExtensionPane.addDeleteListener(new ChangeListener() { @Override public void fireChanged(ChangeEvent event) { //这么写有点问题 String oldName = Utils.objectToString(groupExtensionPane.getSelectedObject()); saveMapInfo(oldName); } }); setPreferredSize(new Dimension(400, 210)); add(groupExtensionPane, BorderLayout.CENTER); addButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/add.png")) { @Override protected void paintBorder(Graphics g) { Graphics2D g2d = (Graphics2D) g; g2d.setStroke(UIConstants.BS); Shape shape = new RoundRectangle2D.Float(0.5f, 0.5f, getWidth() - 1, getHeight() - 1, UIConstants.ARC, UIConstants.ARC); g2d.setColor(UIConstants.LINE_COLOR); g2d.draw(shape); } }; addButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { popupMenu.show(MapGroupExtensionPane.this, addButton.getX() + 1, addButton.getY() + addButton.getHeight()); } }); add(addButton, BorderLayout.SOUTH); initPopupMenu(); } private void initPopupMenu() { popupMenu = new JPopupMenu() { @Override public Dimension getPreferredSize() { Dimension dimension = new Dimension(); dimension.height = super.getPreferredSize().height; dimension.width = addButton.getWidth() - 2; return dimension; } }; JMenuItem worldMap = new JMenuItem(TYPE_NAMES[WORD]); popupMenu.add(worldMap); worldMap.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { groupExtensionPane.addData(TYPE_NAMES[WORD], TYPE_NAMES[WORD], true); } }); JMenuItem countMap = new JMenuItem(TYPE_NAMES[NATION]); popupMenu.add(countMap); countMap.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { groupExtensionPane.addData(TYPE_NAMES[NATION], TYPE_NAMES[NATION], true); } }); JMenuItem proMap = new JMenuItem(TYPE_NAMES[STATE]); popupMenu.add(proMap); proMap.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { groupExtensionPane.addData(TYPE_NAMES[STATE], TYPE_NAMES[STATE], true); } }); JMenuItem menu = new JMenuItem(TYPE_NAMES[USER]); popupMenu.add(menu); menu.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { groupExtensionPane.addData(TYPE_NAMES[USER], TYPE_NAMES[USER], true); } }); } private void doEdit(ChangeEvent e) { MouseEvent event = (MouseEvent) e.getSource(); JPopupMenu editPopMenu = new JPopupMenu(); final String oldName = Utils.objectToString(groupExtensionPane.getSelectedObject()); editPopMenu.add(createAreaItem(oldName)); editPopMenu.add(createMarkerItem(oldName)); editPopMenu.add(createLayerItem(oldName)); editPopMenu.add(createRenameItem()); editPopMenu.show(MapGroupExtensionPane.this, event.getXOnScreen() - OFFSET_X, event.getYOnScreen() - OFFSET_Y); } private void mapCheckBeforeEdit(String name){ if(MapSvgXMLHelper.getInstance().containsMapName(name) || MapSvgXMLHelper.getInstance().getNewMapAttr(name)!=null){ return; } MapSvgAttr attr = new MapSvgAttr(); attr.setFilePath(MapSvgXMLHelper.customMapPath() + CoreConstants.SEPARATOR + name + ".svg"); MapSvgXMLHelper.getInstance().addNewSvgMaps(name,attr); } private JMenuItem createAreaItem(final String oldName) { JMenuItem editFileItem = new JMenuItem(Inter.getLocText(new String[]{"Edit", "Image", "Filed"})); editFileItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { final MapCustomPane image = new MapCustomPane(); image.setImageSelectType(MapShapeValue.AREA); image.populateBean(oldName); image.setTypeNameAndMapName(groupExtensionPane.getSelectedType(), Utils.objectToString(groupExtensionPane.getSelectedObject())); mapCheckBeforeEdit(oldName); final Image oldImage = getMapImage(oldName); BasicDialog dialog = image.showMediumWindow(SwingUtilities.getWindowAncestor(MapGroupExtensionPane.this), new DialogActionAdapter() { public void doOk() { image.updateBean(); // 比较两个前后的名字是否相同, 是图片 如果图片不同, 则直接比较 Image newImage = getMapImage(oldName); if(!ComparatorUtils.equals(oldImage, newImage)) { fireStateChange(); } //versionID递增 MapSvgAttr old = MapSvgXMLHelper.getInstance().getMapAttr(oldName); if(old != null) { old.addVersionID(); } saveMapInfo(oldName); refresh(); } }); dialog.setVisible(true); } }); return editFileItem; } //根据地图的名字返回地图的图片 private Image getMapImage(String mapName) { if (MapSvgXMLHelper.getInstance().containsMapName(mapName)) { MapSvgAttr mapAttr = MapSvgXMLHelper.getInstance().getMapAttr(mapName); if(mapAttr == null) { return null; } return mapAttr.getMapImage(); } return null; } private JMenuItem createMarkerItem(final String oldName) { JMenuItem editMarkerItem = new JMenuItem(Inter.getLocText(new String[]{"Edit", "Image", "Marker"})); editMarkerItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { final MapCustomPane image = new MapCustomPane(); image.setImageSelectType(MapShapeValue.POINT); image.populateBean(oldName); mapCheckBeforeEdit(oldName); final Image oldImage = getMapImage(oldName); BasicDialog dialog = image.showMediumWindow(SwingUtilities.getWindowAncestor(image), new DialogActionAdapter() { public void doOk() { image.updateBean(); Image newImage = getMapImage(oldName); if(!ComparatorUtils.equals(oldImage, newImage)) { fireStateChange(); } //versionID递增 MapSvgAttr old = MapSvgXMLHelper.getInstance().getMapAttr(oldName); if(old != null) { old.addVersionID(); } saveMapInfo(oldName); refresh(); } }); dialog.setVisible(true); } }); return editMarkerItem; } private JMenuItem createLayerItem(final String oldName) { JMenuItem corrItem = new JMenuItem(Inter.getLocText(new String[]{"Filed", "Corresponding_Fields"})); corrItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { final MapDefiAreaNamePane namedPane = new MapDefiAreaNamePane(); namedPane.populateBean(oldName); mapCheckBeforeEdit(oldName); BasicDialog dialog = namedPane.showMediumWindow(SwingUtilities.getWindowAncestor(namedPane), new DialogActionAdapter() { public void doOk() { namedPane.updateBean();// 地图的名称 value对应情况 MapSvgAttr old = MapSvgXMLHelper.getInstance().getMapAttr(oldName); if(old != null) { old.addVersionID(); } saveMapInfo(oldName); } }); dialog.setVisible(true); refresh(); } }); return corrItem; } private void showRenameWaring(String newName){ JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), "\"" + newName + "\"" + Inter.getLocText("Utils-has_been_existed") + "!", Inter.getLocText("FR-Designer_Alert"), JOptionPane.WARNING_MESSAGE); } private JMenuItem createRenameItem() { JMenuItem renameItem = new JMenuItem(Inter.getLocText("FR-Chart-Map_Rename")); renameItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String newName = JOptionPane.showInputDialog(DesignerContext.getDesignerFrame().getContentPane(), Inter.getLocText("FR-Chart-Map_Rename"), groupExtensionPane.getSelectedObject()); if (StringUtils.isNotBlank(newName)) { String oldName = Utils.objectToString(groupExtensionPane.getSelectedObject()); if(ComparatorUtils.equals(oldName, newName)){ return; } //本地在看看临时的helper里面有没有 if(MapSvgXMLHelper.getInstance().getNewMapAttr(newName) != null){ showRenameWaring(newName); return; } try{//提醒名字已存在 if(FRContext.getCurrentEnv().fileExists(StableUtils.pathJoin( new String[]{MapSvgXMLHelper.relativeDefaultMapPath(),newName+SvgProvider.EXTENSION}))){ showRenameWaring(newName); return; } if(FRContext.getCurrentEnv().fileExists(StableUtils.pathJoin( new String[]{MapSvgXMLHelper.relativeCustomMapPath(), newName + SvgProvider.EXTENSION}))){ showRenameWaring(newName); return; } MapSvgAttr editingAttr = MapSvgXMLHelper.getInstance().getMapAttr(oldName); if(editingAttr == null){ editingAttr = MapSvgXMLHelper.getInstance().getNewMapAttr(oldName); } if( editingAttr == null) { return; } editingAttr.renameMap(newName); groupExtensionPane.setValueAtCurrentSelectIndex(newName); fireStateChange(); saveMapInfo(newName); FRContext.getCurrentEnv().deleteFile( StableUtils.pathJoin(new String[]{MapSvgXMLHelper.relativeDefaultMapPath(),oldName+SvgProvider.EXTENSION})); FRContext.getCurrentEnv().deleteFile( StableUtils.pathJoin(new String[]{MapSvgXMLHelper.relativeCustomMapPath(),oldName+SvgProvider.EXTENSION})); refresh(); }catch (Exception exp){ FRLogger.getLogger().error(exp.getMessage()); } } } }); return renameItem; } private void refresh() { this.validate(); this.repaint(); DesignerFrame frame = DesignerContext.getDesignerFrame(); if(frame != null) { frame.repaint();//kunsnat: 图表属性没变, 只是读取时 内容变化. } } //保存修改过的地图信息 private void saveMapInfo(final String mapName) { SwingWorker worker = new SwingWorker() { @Override protected Integer doInBackground() throws Exception { MapSvgAttr attr = MapSvgXMLHelper.getInstance().getMapAttr(mapName);// 只有在编辑地图时才需要储存相关数据 @kuns if(attr != null){ attr.writeBack(mapName); } return 0; } @Override protected void done() { FRLogger.getLogger().info(Inter.getLocText("FR-Chart-Map_Saved")); // 地图已经保存. } }; worker.execute(); DesignerEnvManager.addWorkers(worker); } private void fireStateChange() { for (int i = changeListeners.size(); i > 0; i--) { changeListeners.get(i - 1).stateChanged(new javax.swing.event.ChangeEvent(this)); } } /** * 更新地图属性 * @return 返回地图名称. */ public String updateBean(MapPlot plot) { if(!hasPopulated){ this.populateBean(plot); hasPopulated = true; } MapHelper helper = plot.isSvgMap() ? MapSvgXMLHelper.getInstance() : MapXMLHelper.getInstance(); helper.clearCateNames(); for (String type : TYPE_NAMES) { Object[] datas = groupExtensionPane.getData(type); for (Object name : datas) { helper.addCateNames(type, name); } } return Utils.objectToString(groupExtensionPane.getSelectedObject()); } /** * 更新地图名称 * @param mapPlot 地图 */ public void populateBean(MapPlot mapPlot) { hasPopulated = false; groupExtensionPane.clearData(); for (String type : TYPE_NAMES) { MapHelper helper = mapPlot.isSvgMap() ? MapSvgXMLHelper.getInstance() : MapXMLHelper.getInstance(); java.util.List list = helper.getNamesListWithCateName(type); for (Object name : list) { groupExtensionPane.addData(name, type); } } groupExtensionPane.setSelectedObject(mapPlot.getMapName()); hasPopulated = true; } /** * 给组件登记一个观察者监听事件 * * @param listener 观察者监听事件 */ public void registerChangeListener(final UIObserverListener listener) { changeListeners.add(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent e) { listener.doChange(); } }); } /** * 组件是否需要响应添加的观察者事件 * * @return 如果需要响应观察者事件则返回true,否则返回false */ public boolean shouldResponseChangeListener() { return true; } public void setEnabled(boolean isEnabled){ super.setEnabled(isEnabled); addButton.setEnabled(isEnabled); popupMenu.setEnabled(isEnabled); groupExtensionPane.setEnabled(isEnabled); } } \ No newline at end of file +package com.fr.design.chart.series.PlotSeries; import com.fr.base.*; import com.fr.chart.base.MapSvgAttr; import com.fr.chart.base.MapSvgXMLHelper; import com.fr.chart.chartattr.MapPlot; import com.fr.chart.chartglyph.MapShapeValue; import com.fr.design.DesignerEnvManager; import com.fr.design.constants.UIConstants; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.event.ChangeEvent; import com.fr.design.event.ChangeListener; import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserverListener; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerFrame; import com.fr.general.ComparatorUtils; import com.fr.general.FRLogger; import com.fr.general.Inter; import com.fr.stable.CoreConstants; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.stable.SvgProvider; import javax.swing.*; import javax.swing.event.ListSelectionEvent; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseEvent; import java.awt.geom.RoundRectangle2D; import java.util.ArrayList; /** * Created by IntelliJ IDEA. * Author : Richer * Version: 7.0.3 * Date: 12-12-29 * Time: 下午2:41 */ public class MapGroupExtensionPane extends BasicPane implements UIObserver { private static final String[] TYPE_NAMES = new String[]{ Inter.getLocText("FR-Chart-World_Map"), Inter.getLocText("FR-Chart-State_Map"), Inter.getLocText("FR-Chart-Province_Map"), Inter.getLocText("FR-Chart-Custom_Map")}; private static final int WORD = 0; private static final int NATION = 1; private static final int STATE = 2; private static final int USER = 3; private static final int OFFSET_X = 800; private static final int OFFSET_Y = 200; private UIGroupExtensionPane groupExtensionPane; private UIButton addButton; private JPopupMenu popupMenu; private ArrayList changeListeners = new ArrayList(); private boolean hasPopulated = false; @Override protected String title4PopupWindow() { return "Map"; } public MapGroupExtensionPane() { setLayout(new BorderLayout()); groupExtensionPane = new UIGroupExtensionPane(TYPE_NAMES){ /** * 新添加的数据的序号 * @param data 数据 */ protected void dealNewAddedDataIndex(Object data){ String newName = (String)data; MapSvgXMLHelper helper = MapSvgXMLHelper.getInstance(); if(helper.getNewMapAttr(newName) != null){ return; } MapSvgAttr attr = new MapSvgAttr(); attr.setFilePath(MapSvgXMLHelper.customMapPath() + CoreConstants.SEPARATOR + newName + ".svg"); helper.addNewSvgMaps(attr.getName(), attr); } /** * 一次鼠标的点击会有两次事件响应(按下和释放)。前者的事件属性中getValueIsAdjusting()=true,后者是false。 * 是否响应list值改变 * @return 鼠标按下时不响应,先响应mousePress事件,在鼠标释放是再响应list值改编的事件,并且点击删除不触发更新,并且populate后触发更新 */ protected boolean isRespondToValueChange(ListSelectionEvent e){ return !e.getValueIsAdjusting() && !this.isPressOnDelete() && hasPopulated; } }; groupExtensionPane.addSelectionChangeListener(new ChangeListener() { @Override public void fireChanged(ChangeEvent event) { fireStateChange(); } }); groupExtensionPane.addItemEditListener(new ChangeListener() { @Override public void fireChanged(ChangeEvent event) { doEdit(event); } }); groupExtensionPane.addDeleteListener(new ChangeListener() { @Override public void fireChanged(ChangeEvent event) { //这么写有点问题 String oldName = Utils.objectToString(groupExtensionPane.getSelectedObject()); saveMapInfo(oldName); } }); setPreferredSize(new Dimension(400, 210)); add(groupExtensionPane, BorderLayout.CENTER); addButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/add.png")) { @Override protected void paintBorder(Graphics g) { Graphics2D g2d = (Graphics2D) g; g2d.setStroke(UIConstants.BS); Shape shape = new RoundRectangle2D.Float(0.5f, 0.5f, getWidth() - 1, getHeight() - 1, UIConstants.ARC, UIConstants.ARC); g2d.setColor(UIConstants.LINE_COLOR); g2d.draw(shape); } }; addButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { popupMenu.show(MapGroupExtensionPane.this, addButton.getX() + 1, addButton.getY() + addButton.getHeight()); } }); add(addButton, BorderLayout.SOUTH); initPopupMenu(); } private void initPopupMenu() { popupMenu = new JPopupMenu() { @Override public Dimension getPreferredSize() { Dimension dimension = new Dimension(); dimension.height = super.getPreferredSize().height; dimension.width = addButton.getWidth() - 2; return dimension; } }; JMenuItem worldMap = new JMenuItem(TYPE_NAMES[WORD]); popupMenu.add(worldMap); worldMap.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { groupExtensionPane.addData(TYPE_NAMES[WORD], TYPE_NAMES[WORD], true); } }); JMenuItem countMap = new JMenuItem(TYPE_NAMES[NATION]); popupMenu.add(countMap); countMap.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { groupExtensionPane.addData(TYPE_NAMES[NATION], TYPE_NAMES[NATION], true); } }); JMenuItem proMap = new JMenuItem(TYPE_NAMES[STATE]); popupMenu.add(proMap); proMap.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { groupExtensionPane.addData(TYPE_NAMES[STATE], TYPE_NAMES[STATE], true); } }); JMenuItem menu = new JMenuItem(TYPE_NAMES[USER]); popupMenu.add(menu); menu.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { groupExtensionPane.addData(TYPE_NAMES[USER], TYPE_NAMES[USER], true); } }); } private void doEdit(ChangeEvent e) { MouseEvent event = (MouseEvent) e.getSource(); JPopupMenu editPopMenu = new JPopupMenu(); final String oldName = Utils.objectToString(groupExtensionPane.getSelectedObject()); editPopMenu.add(createAreaItem(oldName)); editPopMenu.add(createMarkerItem(oldName)); editPopMenu.add(createLayerItem(oldName)); editPopMenu.add(createRenameItem()); editPopMenu.show(MapGroupExtensionPane.this, event.getXOnScreen() - OFFSET_X, event.getYOnScreen() - OFFSET_Y); } private void mapCheckBeforeEdit(String name){ if(MapSvgXMLHelper.getInstance().containsMapName(name) || MapSvgXMLHelper.getInstance().getNewMapAttr(name)!=null){ return; } MapSvgAttr attr = new MapSvgAttr(); attr.setFilePath(MapSvgXMLHelper.customMapPath() + CoreConstants.SEPARATOR + name + ".svg"); MapSvgXMLHelper.getInstance().addNewSvgMaps(name,attr); } private JMenuItem createAreaItem(final String oldName) { JMenuItem editFileItem = new JMenuItem(Inter.getLocText(new String[]{"Edit", "Image", "Filed"})); editFileItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { final MapCustomPane image = new MapCustomPane(); image.setImageSelectType(MapShapeValue.AREA); image.populateBean(oldName); image.setTypeNameAndMapName(groupExtensionPane.getSelectedType(), Utils.objectToString(groupExtensionPane.getSelectedObject())); mapCheckBeforeEdit(oldName); final Image oldImage = getMapImage(oldName); BasicDialog dialog = image.showMediumWindow(SwingUtilities.getWindowAncestor(MapGroupExtensionPane.this), new DialogActionAdapter() { public void doOk() { image.updateBean(); // 比较两个前后的名字是否相同, 是图片 如果图片不同, 则直接比较 Image newImage = getMapImage(oldName); if(!ComparatorUtils.equals(oldImage, newImage)) { fireStateChange(); } //versionID递增 MapSvgAttr old = MapSvgXMLHelper.getInstance().getMapAttr(oldName); if(old != null) { old.addVersionID(); } saveMapInfo(oldName); refresh(); } }); dialog.setVisible(true); } }); return editFileItem; } //根据地图的名字返回地图的图片 private Image getMapImage(String mapName) { if (MapSvgXMLHelper.getInstance().containsMapName(mapName)) { MapSvgAttr mapAttr = MapSvgXMLHelper.getInstance().getMapAttr(mapName); if(mapAttr == null) { return null; } return mapAttr.getMapImage(); } return null; } private JMenuItem createMarkerItem(final String oldName) { JMenuItem editMarkerItem = new JMenuItem(Inter.getLocText(new String[]{"Edit", "Image", "Marker"})); editMarkerItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { final MapCustomPane image = new MapCustomPane(); image.setImageSelectType(MapShapeValue.POINT); image.populateBean(oldName); mapCheckBeforeEdit(oldName); final Image oldImage = getMapImage(oldName); BasicDialog dialog = image.showMediumWindow(SwingUtilities.getWindowAncestor(image), new DialogActionAdapter() { public void doOk() { image.updateBean(); Image newImage = getMapImage(oldName); if(!ComparatorUtils.equals(oldImage, newImage)) { fireStateChange(); } //versionID递增 MapSvgAttr old = MapSvgXMLHelper.getInstance().getMapAttr(oldName); if(old != null) { old.addVersionID(); } saveMapInfo(oldName); refresh(); } }); dialog.setVisible(true); } }); return editMarkerItem; } private JMenuItem createLayerItem(final String oldName) { JMenuItem corrItem = new JMenuItem(Inter.getLocText(new String[]{"Filed", "Corresponding_Fields"})); corrItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { final MapDefiAreaNamePane namedPane = new MapDefiAreaNamePane(); namedPane.populateBean(oldName); mapCheckBeforeEdit(oldName); BasicDialog dialog = namedPane.showMediumWindow(SwingUtilities.getWindowAncestor(namedPane), new DialogActionAdapter() { public void doOk() { namedPane.updateBean();// 地图的名称 value对应情况 MapSvgAttr old = MapSvgXMLHelper.getInstance().getMapAttr(oldName); if(old != null) { old.addVersionID(); } saveMapInfo(oldName); } }); dialog.setVisible(true); refresh(); } }); return corrItem; } private void showRenameWaring(String newName){ JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), "\"" + newName + "\"" + Inter.getLocText("Utils-has_been_existed") + "!", Inter.getLocText("FR-Designer_Alert"), JOptionPane.WARNING_MESSAGE); } private JMenuItem createRenameItem() { JMenuItem renameItem = new JMenuItem(Inter.getLocText("FR-Chart-Map_Rename")); renameItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String newName = JOptionPane.showInputDialog(DesignerContext.getDesignerFrame().getContentPane(), Inter.getLocText("FR-Chart-Map_Rename"), groupExtensionPane.getSelectedObject()); if (StringUtils.isNotBlank(newName)) { String oldName = Utils.objectToString(groupExtensionPane.getSelectedObject()); if(ComparatorUtils.equals(oldName, newName)){ return; } //本地在看看临时的helper里面有没有 if(MapSvgXMLHelper.getInstance().getNewMapAttr(newName) != null){ showRenameWaring(newName); return; } try{//提醒名字已存在 if(FRContext.getCurrentEnv().fileExists(StableUtils.pathJoin( new String[]{MapSvgXMLHelper.relativeDefaultMapPath(),newName+SvgProvider.EXTENSION}))){ showRenameWaring(newName); return; } if(FRContext.getCurrentEnv().fileExists(StableUtils.pathJoin( new String[]{MapSvgXMLHelper.relativeCustomMapPath(), newName + SvgProvider.EXTENSION}))){ showRenameWaring(newName); return; } MapSvgAttr editingAttr = MapSvgXMLHelper.getInstance().getMapAttr(oldName); if(editingAttr == null){ editingAttr = MapSvgXMLHelper.getInstance().getNewMapAttr(oldName); } if( editingAttr == null) { return; } editingAttr.renameMap(newName); groupExtensionPane.setValueAtCurrentSelectIndex(newName); fireStateChange(); saveMapInfo(newName); FRContext.getCurrentEnv().deleteFile( StableUtils.pathJoin(new String[]{MapSvgXMLHelper.relativeDefaultMapPath(),oldName+SvgProvider.EXTENSION})); FRContext.getCurrentEnv().deleteFile( StableUtils.pathJoin(new String[]{MapSvgXMLHelper.relativeCustomMapPath(),oldName+SvgProvider.EXTENSION})); refresh(); }catch (Exception exp){ FRLogger.getLogger().error(exp.getMessage()); } } } }); return renameItem; } private void refresh() { this.validate(); this.repaint(); DesignerFrame frame = DesignerContext.getDesignerFrame(); if(frame != null) { frame.repaint();//kunsnat: 图表属性没变, 只是读取时 内容变化. } } //保存修改过的地图信息 private void saveMapInfo(final String mapName) { SwingWorker worker = new SwingWorker() { @Override protected Integer doInBackground() throws Exception { MapSvgAttr attr = MapSvgXMLHelper.getInstance().getMapAttr(mapName);// 只有在编辑地图时才需要储存相关数据 @kuns if(attr != null){ attr.writeBack(mapName); } return 0; } @Override protected void done() { FRLogger.getLogger().info(Inter.getLocText("FR-Chart-Map_Saved")); // 地图已经保存. } }; worker.execute(); DesignerEnvManager.addWorkers(worker); } private void fireStateChange() { for (int i = changeListeners.size(); i > 0; i--) { changeListeners.get(i - 1).stateChanged(new javax.swing.event.ChangeEvent(this)); } } /** * 更新地图属性 * @return 返回地图名称. */ public String updateBean(MapPlot plot) { if(!hasPopulated){ this.populateBean(plot); hasPopulated = true; } MapHelper helper = plot.isSvgMap() ? MapSvgXMLHelper.getInstance() : MapXMLHelper.getInstance(); helper.clearCateNames(); for (String type : TYPE_NAMES) { Object[] datas = groupExtensionPane.getData(type); for (Object name : datas) { helper.addCateNames(type, name); } } return Utils.objectToString(groupExtensionPane.getSelectedObject()); } /** * 更新地图名称 * @param mapPlot 地图 */ public void populateBean(MapPlot mapPlot) { hasPopulated = false; groupExtensionPane.clearData(); for (String type : TYPE_NAMES) { MapHelper helper = mapPlot.isSvgMap() ? MapSvgXMLHelper.getInstance() : MapXMLHelper.getInstance(); java.util.List list = helper.getNamesListWithCateName(type); for (Object name : list) { groupExtensionPane.addData(name, type); } } groupExtensionPane.setSelectedObject(mapPlot.getMapName()); hasPopulated = true; } /** * 给组件登记一个观察者监听事件 * * @param listener 观察者监听事件 */ public void registerChangeListener(final UIObserverListener listener) { changeListeners.add(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent e) { listener.doChange(); } }); } /** * 组件是否需要响应添加的观察者事件 * * @return 如果需要响应观察者事件则返回true,否则返回false */ public boolean shouldResponseChangeListener() { return true; } public void setEnabled(boolean isEnabled){ super.setEnabled(isEnabled); addButton.setEnabled(isEnabled); popupMenu.setEnabled(isEnabled); groupExtensionPane.setEnabled(isEnabled); } } \ No newline at end of file diff --git a/designer_chart/src/com/fr/design/chart/series/PlotSeries/MapImageEditPane.java b/designer_chart/src/com/fr/design/chart/series/PlotSeries/MapImageEditPane.java index 4aff10c37..55a3e079e 100644 --- a/designer_chart/src/com/fr/design/chart/series/PlotSeries/MapImageEditPane.java +++ b/designer_chart/src/com/fr/design/chart/series/PlotSeries/MapImageEditPane.java @@ -1,9 +1,9 @@ package com.fr.design.chart.series.PlotSeries; import com.fr.base.BaseUtils; -import com.fr.base.MapSvgAttr; -import com.fr.base.MapSvgXMLHelper; import com.fr.base.Utils; +import com.fr.chart.base.MapSvgAttr; +import com.fr.chart.base.MapSvgXMLHelper; import com.fr.chart.chartglyph.MapShapeValue; import com.fr.design.beans.BasicBeanPane; import com.fr.design.dialog.DialogActionAdapter; diff --git a/designer_chart/src/com/fr/design/chart/series/PlotSeries/UIGroupExtensionPane.java b/designer_chart/src/com/fr/design/chart/series/PlotSeries/UIGroupExtensionPane.java index 1e26f37b0..2ad670341 100644 --- a/designer_chart/src/com/fr/design/chart/series/PlotSeries/UIGroupExtensionPane.java +++ b/designer_chart/src/com/fr/design/chart/series/PlotSeries/UIGroupExtensionPane.java @@ -1 +1 @@ -package com.fr.design.chart.series.PlotSeries; import com.fr.base.MapSvgXMLHelper; import com.fr.design.constants.LayoutConstants; import com.fr.design.constants.UIConstants; import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.UIDialog; import com.fr.design.event.ChangeEvent; import com.fr.design.event.ChangeListener; import com.fr.design.gui.frpane.UIExtensionPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.BoldFontTextLabel; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextfield.UISearchTextField; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.DesignerContext; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.ComparatorUtils; import com.fr.general.FRLogger; import com.fr.general.GeneralUtils; import com.fr.general.Inter; import com.fr.stable.ArrayUtils; import javax.swing.*; import javax.swing.border.Border; import javax.swing.event.*; import java.awt.*; import java.awt.event.*; import java.util.ArrayList; import java.util.List; /** * Created by IntelliJ IDEA. * Author : Richer * Version: 7.0.3 * Date: 12-12-29 * Time: 上午11:14 * 可收缩的面板,只有两层 */ public class UIGroupExtensionPane extends BasicPane { public static final String EDIT = "edit"; public static final String DELETE = "delete"; private static final int BUTTONWIDTH = 16; private static final int DIALOG_WIDTH = 140; private static final int DIALOG_HEIGHT = 100; private UISearchTextField searchTextFiled; private JList[] contentViews; private Component[][] components; private String[] titles; private java.util.List selectionListeners = new ArrayList(); private java.util.List editListeners = new ArrayList(); private List deleteListeners = new ArrayList(); private boolean isPressOnDelete = false; // 是否点击在删除按钮上 @Override protected String title4PopupWindow() { return "group"; } public UIGroupExtensionPane(String[] titles) { this.titles = titles; if (ArrayUtils.isEmpty(titles)) { return; } initComponents(titles); } private void initComponents(String[] titles) { setBackground(null); searchTextFiled = initSearchTextField(); int count = titles.length; contentViews = new JList[count]; components = new Component[count + 1][]; double p = TableLayout.PREFERRED; double f = TableLayout.FILL; double[] rowSize = new double[count + 1]; double[] columnSize = {f}; for (int i = 0; i < count + 1; i++) { rowSize[i] = p; if (i == 0) { components[i] = new Component[]{searchTextFiled}; } else if (i > 0 && i < count + 1) { JList li = new JList(new DefaultListModel()); li.addListSelectionListener(listSelectionListener); li.addMouseListener(mouseListener); li.setCellRenderer(listCellRenderer); li.setBackground(null); contentViews[i - 1] = li; components[i] = new UIExtensionPane[]{new UIExtensionPane(titles[i - 1], li, false)}; } } JPanel centerPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 0, 0); setLayout(new BorderLayout()); add(new UIScrollPane(centerPane), BorderLayout.CENTER); } private UISearchTextField initSearchTextField() { UISearchTextField searchTextFiled = new UISearchTextField() { public Dimension getPreferredSize() { return new Dimension(120, 22); } }; searchTextFiled.setIconPosition(SwingConstants.RIGHT); searchTextFiled.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { doFilter(); } @Override public void removeUpdate(DocumentEvent e) { doFilter(); } @Override public void changedUpdate(DocumentEvent e) { doFilter(); } }); return searchTextFiled; } /** * 返回index列表的数据 */ public Object[] getData(int index) { if (index < 0 || index > contentViews.length) { return ArrayUtils.EMPTY_OBJECT_ARRAY; } ListModel model = contentViews[index].getModel(); Object[] items = new Object[model.getSize()]; for (int i = 0, len = model.getSize(); i < len; i++) { items[i] = model.getElementAt(i); } return items; } /** * 返回对应Title的列表数组 */ public Object[] getData(String title) { int dataIndex = ArrayUtils.indexOf(titles, title); if (dataIndex != ArrayUtils.INDEX_NOT_FOUND) { return getData(dataIndex); } return ArrayUtils.EMPTY_OBJECT_ARRAY; } private void doFilter() { for (JList list : contentViews) { ListDataListener[] ls = ((DefaultListModel) list.getModel()).getListDataListeners(); for (ListDataListener l : ls) { l.contentsChanged(new ListDataEvent(l, ListDataEvent.CONTENTS_CHANGED, 0, list.getModel().getSize())); } } for (int i = 1, len = components.length; i < len; i++) { ((UIExtensionPane) components[i][0]).setExpand(true); } } /** * 获取选中的值 * * @return 选中的值 */ public Object getSelectedObject() { for (JList list : contentViews) { if (list.getSelectedValue() != null) { return list.getSelectedValue(); } } return null; } /** * 返回选中的类别 * @return 类别 */ public String getSelectedType(){ for (int i = 0, len = contentViews.length; i < len; i++) { if(contentViews[i].getSelectedValue() != null){ return titles[i]; } } return ""; } /** * 设置选中的数据 */ public void setSelectedObject(Object value) { for (int i = 0, len = contentViews.length; i < len; i++) { UIExtensionPane extensionPane = (UIExtensionPane) components[i + 1][0]; JList list = contentViews[i]; DefaultListModel model = (DefaultListModel) list.getModel(); extensionPane.setExpand(model.contains(value)); if (model.contains(value)) { list.setSelectedValue(value, true); } } } /** * 设置数据选中的序号. */ public void setValueAtCurrentSelectIndex(Object value) { for (JList list : contentViews) { if (list.getSelectedIndex() != -1) { ((DefaultListModel) list.getModel()).setElementAt(value, list.getSelectedIndex()); } } } /** * 根据索引来添加数据 * * @param data 要添加的数据 * @param index 要添加的数据向的索引 */ public void addData(Object data, int index) { addData(data, index, false); } /** * 根据索引来添加数据 * * @param data 要添加的数据 * @param index 要添加的数据向的索引 * @param checkRepeat 是否检查名字重复 */ public void addData(Object data, int index, boolean checkRepeat) { if (contentViews == null || index < 0 || index > contentViews.length - 1) { return; } JList list = contentViews[index]; DefaultListModel model = (DefaultListModel) list.getModel(); if (data instanceof String) { model.addElement(createUnrepeatedName(model, (String) data, checkRepeat)); } if (checkRepeat) { // 将添加类型以外的其他类型都收起来 for (int i = 1, len = components.length; i < len; i++) { ((UIExtensionPane) components[i][0]).setExpand(false); } ((UIExtensionPane) components[index + 1][0]).setExpand(true); int selectedIndex = list.getModel().getSize() - 1; list.setSelectedIndex(selectedIndex); dealNewAddedDataIndex(((DefaultListModel) list.getModel()).elementAt(selectedIndex)); } } /** * 新添加的数据的序号 * @param data 数据 */ protected void dealNewAddedDataIndex(Object data){ } /** * 根据标题来添加数据 * * @param data 要添加的数据 * @param title 要添加数据的项的标题文字 */ public void addData(Object data, String title) { addData(data, title, false); } /** * 根据标题来添加数据 * * @param data 要添加的数据 * @param title 要添加数据的项的标题文字 * @param checkRepeat 是否检查名字重复 */ public void addData(Object data, String title, boolean checkRepeat) { int addIndex = ArrayUtils.indexOf(titles, title); if (addIndex != ArrayUtils.INDEX_NOT_FOUND) { addData(data, addIndex, checkRepeat); } } /** * 清除所有的数据 */ public void clearData() { for (JList list : contentViews) { ((DefaultListModel) list.getModel()).clear(); } } private String createUnrepeatedName(DefaultListModel model, String name, boolean checkRepeat) { if (!checkRepeat) { return name; } int count = model.getSize(); int extra = 1; String newName = name + (count + extra); boolean hasRepeated = false; do { hasRepeated = false; newName = name + (count + extra); for (int i = 0; i < count; i++) { if (ComparatorUtils.equals(model.getElementAt(i), newName)) { hasRepeated = true; extra++; } } } while (hasRepeated); return name + (count + extra); } /** * 判断该控件是否应该有编辑操作 * * @param list 列表组件 * @return 如果有编辑操作则需要显示相应的图标 */ private boolean hasEditOperation(JList list) { return true; } private DefaultListCellRenderer listCellRenderer = new DefaultListCellRenderer() { public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { JComponent c = (JComponent) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (!hasEditOperation(list)) { return c; } Border border = null; c.setBorder(border); UILabel editLabel = new UILabel(UIConstants.EDIT_ICON); UILabel deleteLabel = new UILabel(UIConstants.DELETE_ICON); JPanel editPane = GUICoreUtils.createFlowPane(new Component[]{editLabel, deleteLabel}, FlowLayout.LEFT, LayoutConstants.HGAP_LARGE); editPane.setBackground(isSelected ? c.getBackground() : null); editPane.setBorder(border); JPanel renderPane = GUICoreUtils.createBorderLayoutPane(c, BorderLayout.CENTER, editPane, BorderLayout.EAST); if (shouldFilter(value)) { renderPane.setPreferredSize(new Dimension(0, 0)); } return renderPane; } }; //事件发生的顺序是ListSelection、MousePressed、ListSelection、MouseReleased private ListSelectionListener listSelectionListener = new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { //在鼠标按下的时候的值改变事件,重置属性 if(e.getValueIsAdjusting()){ isPressOnDelete = false; } if(!isRespondToValueChange(e)){ return; } fireSelectionChangeListener(new ChangeEvent(e.getSource())); if (((JList) e.getSource()).getSelectedIndex() == -1) { return; } for (JList list : contentViews) { if (list.getSelectedIndex() != -1 && !ComparatorUtils.equals(list, e.getSource())) { try { list.setSelectedIndices(null); } catch (Exception ee) { } } } } }; /** * 是否响应list值改变 * @return 响应 */ protected boolean isRespondToValueChange(ListSelectionEvent e){ return true; } private boolean shouldFilter(Object value) { return !GeneralUtils.objectToString(value).toLowerCase().contains(searchTextFiled.getText().toLowerCase()); } private MouseListener mouseListener = new MouseAdapter() { /** * {@inheritDoc} */ @Override public void mousePressed(final MouseEvent e) { isPressOnDelete = false; final JList list = (JList) e.getSource(); Point point = e.getPoint(); final int index = list.locationToIndex(point); int width = list.getWidth(); if (hasEditOperation(list)) { // 删除按钮 if (point.x > width - (BUTTONWIDTH + LayoutConstants.HGAP_LARGE)) { BasicPane bp = new BasicPane() { protected String title4PopupWindow() { return ""; } }; isPressOnDelete = true; bp.setLayout(new BorderLayout()); bp.add(new BoldFontTextLabel(Inter.getLocText(new String[]{"Delete", "Chart-Map"}) + "?", SwingConstants.CENTER)); clearLastListSelection(list); final String selectedType = UIGroupExtensionPane.this.getSelectedType(); UIDialog dialog = bp.showUnsizedWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { public void doOk() { Object name = getSelectedObject(); ((DefaultListModel) list.getModel()).removeElementAt(index); MapSvgXMLHelper.getInstance().removeMapAttr(GeneralUtils.objectToString(name)); MapSvgXMLHelper.getInstance().removeCateNames(selectedType,GeneralUtils.objectToString(name)); fireDeleteListener(new ChangeEvent(e)); } }); dialog.setResizable(true); dialog.setSize(DIALOG_WIDTH, DIALOG_HEIGHT); dialog.setResizable(false); GUICoreUtils.centerWindow(dialog); dialog.setVisible(true); } // 编辑按钮 else if (point.x > width - (BUTTONWIDTH * 2 + 2 * LayoutConstants.HGAP_LARGE) && point.x < width - (BUTTONWIDTH + LayoutConstants.HGAP_LARGE)) { fireItemEditListener(new ChangeEvent(e)); } } } public void mouseReleased(MouseEvent e) { isPressOnDelete = false; } }; /** * 直接跨list点击删除按钮,要置之前list的选中项为空(因为删除操作不触发更新) * @param currentList 当前选中的list */ public void clearLastListSelection (JList currentList) { for (JList list : contentViews) { if (list.getSelectedIndex() != -1 && !ComparatorUtils.equals(list, currentList)) { try { list.setSelectedIndices(null); } catch (Exception e) { FRLogger.getLogger().error(e.getMessage()); } } } } /** * 是否点击在删除按钮上 * @return 是则返回true */ public boolean isPressOnDelete(){ return isPressOnDelete; } /** * 添加选中变化监听事件 * @param listener 监听 */ public void addSelectionChangeListener(ChangeListener listener) { selectionListeners.add(listener); } private void fireSelectionChangeListener(ChangeEvent e) { for (int i = selectionListeners.size(); i > 0; i--) { selectionListeners.get(i - 1).fireChanged(e); } } /** * 添加Item的监听事件 * @param listener 监听器 */ public void addItemEditListener(ChangeListener listener) { editListeners.add(listener); } private void fireItemEditListener(ChangeEvent e) { for (int i = editListeners.size(); i > 0; i--) { editListeners.get(i - 1).fireChanged(e); } } /** * 添加删除事件的监听事件 * @param listener 监听 */ public void addDeleteListener(ChangeListener listener) { deleteListeners.add(listener); } private void fireDeleteListener(ChangeEvent e) { for(int i = deleteListeners.size(); i > 0; i--) { deleteListeners.get(i - 1).fireChanged(e); } } public void setEnabled(boolean isEnabled){ super.setEnabled(isEnabled); if(searchTextFiled != null){ searchTextFiled.setEnabled(isEnabled); } if(this.components != null){ for(int i = 0; i < this.components.length; i++){ Component[] comp = this.components[i]; for(int j = 0; j < comp.length; j++){ comp[j].setEnabled(isEnabled); } } } } /** * 测试程序 * @param args 参数 */ public static void main(String[] args) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container c = f.getContentPane(); c.setBackground(Color.WHITE); c.setLayout(new BoxLayout(c, BoxLayout.Y_AXIS)); final UIGroupExtensionPane g = new UIGroupExtensionPane(new String[]{"title1", "title2", "title3"}); c.add(g, BorderLayout.CENTER); JPanel pp = new JPanel(new FlowLayout()); c.add(pp, BorderLayout.SOUTH); UIButton test = new UIButton("add1"); test.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { g.addData("test111", 0); } }); pp.add(test); UIButton test2 = new UIButton("add2"); test2.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { g.addData("test222", 1); } }); pp.add(test2); f.setSize(360, 500); f.setLocation(200, 100); f.setVisible(true); } } \ No newline at end of file +package com.fr.design.chart.series.PlotSeries; import com.fr.chart.base.MapSvgXMLHelper; import com.fr.design.constants.LayoutConstants; import com.fr.design.constants.UIConstants; import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.UIDialog; import com.fr.design.event.ChangeEvent; import com.fr.design.event.ChangeListener; import com.fr.design.gui.frpane.UIExtensionPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.BoldFontTextLabel; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextfield.UISearchTextField; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.DesignerContext; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.ComparatorUtils; import com.fr.general.FRLogger; import com.fr.general.GeneralUtils; import com.fr.general.Inter; import com.fr.stable.ArrayUtils; import javax.swing.*; import javax.swing.border.Border; import javax.swing.event.*; import java.awt.*; import java.awt.event.*; import java.util.ArrayList; import java.util.List; /** * Created by IntelliJ IDEA. * Author : Richer * Version: 7.0.3 * Date: 12-12-29 * Time: 上午11:14 * 可收缩的面板,只有两层 */ public class UIGroupExtensionPane extends BasicPane { public static final String EDIT = "edit"; public static final String DELETE = "delete"; private static final int BUTTONWIDTH = 16; private static final int DIALOG_WIDTH = 140; private static final int DIALOG_HEIGHT = 100; private UISearchTextField searchTextFiled; private JList[] contentViews; private Component[][] components; private String[] titles; private java.util.List selectionListeners = new ArrayList(); private java.util.List editListeners = new ArrayList(); private List deleteListeners = new ArrayList(); private boolean isPressOnDelete = false; // 是否点击在删除按钮上 @Override protected String title4PopupWindow() { return "group"; } public UIGroupExtensionPane(String[] titles) { this.titles = titles; if (ArrayUtils.isEmpty(titles)) { return; } initComponents(titles); } private void initComponents(String[] titles) { setBackground(null); searchTextFiled = initSearchTextField(); int count = titles.length; contentViews = new JList[count]; components = new Component[count + 1][]; double p = TableLayout.PREFERRED; double f = TableLayout.FILL; double[] rowSize = new double[count + 1]; double[] columnSize = {f}; for (int i = 0; i < count + 1; i++) { rowSize[i] = p; if (i == 0) { components[i] = new Component[]{searchTextFiled}; } else if (i > 0 && i < count + 1) { JList li = new JList(new DefaultListModel()); li.addListSelectionListener(listSelectionListener); li.addMouseListener(mouseListener); li.setCellRenderer(listCellRenderer); li.setBackground(null); contentViews[i - 1] = li; components[i] = new UIExtensionPane[]{new UIExtensionPane(titles[i - 1], li, false)}; } } JPanel centerPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 0, 0); setLayout(new BorderLayout()); add(new UIScrollPane(centerPane), BorderLayout.CENTER); } private UISearchTextField initSearchTextField() { UISearchTextField searchTextFiled = new UISearchTextField() { public Dimension getPreferredSize() { return new Dimension(120, 22); } }; searchTextFiled.setIconPosition(SwingConstants.RIGHT); searchTextFiled.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { doFilter(); } @Override public void removeUpdate(DocumentEvent e) { doFilter(); } @Override public void changedUpdate(DocumentEvent e) { doFilter(); } }); return searchTextFiled; } /** * 返回index列表的数据 */ public Object[] getData(int index) { if (index < 0 || index > contentViews.length) { return ArrayUtils.EMPTY_OBJECT_ARRAY; } ListModel model = contentViews[index].getModel(); Object[] items = new Object[model.getSize()]; for (int i = 0, len = model.getSize(); i < len; i++) { items[i] = model.getElementAt(i); } return items; } /** * 返回对应Title的列表数组 */ public Object[] getData(String title) { int dataIndex = ArrayUtils.indexOf(titles, title); if (dataIndex != ArrayUtils.INDEX_NOT_FOUND) { return getData(dataIndex); } return ArrayUtils.EMPTY_OBJECT_ARRAY; } private void doFilter() { for (JList list : contentViews) { ListDataListener[] ls = ((DefaultListModel) list.getModel()).getListDataListeners(); for (ListDataListener l : ls) { l.contentsChanged(new ListDataEvent(l, ListDataEvent.CONTENTS_CHANGED, 0, list.getModel().getSize())); } } for (int i = 1, len = components.length; i < len; i++) { ((UIExtensionPane) components[i][0]).setExpand(true); } } /** * 获取选中的值 * * @return 选中的值 */ public Object getSelectedObject() { for (JList list : contentViews) { if (list.getSelectedValue() != null) { return list.getSelectedValue(); } } return null; } /** * 返回选中的类别 * @return 类别 */ public String getSelectedType(){ for (int i = 0, len = contentViews.length; i < len; i++) { if(contentViews[i].getSelectedValue() != null){ return titles[i]; } } return ""; } /** * 设置选中的数据 */ public void setSelectedObject(Object value) { for (int i = 0, len = contentViews.length; i < len; i++) { UIExtensionPane extensionPane = (UIExtensionPane) components[i + 1][0]; JList list = contentViews[i]; DefaultListModel model = (DefaultListModel) list.getModel(); extensionPane.setExpand(model.contains(value)); if (model.contains(value)) { list.setSelectedValue(value, true); } } } /** * 设置数据选中的序号. */ public void setValueAtCurrentSelectIndex(Object value) { for (JList list : contentViews) { if (list.getSelectedIndex() != -1) { ((DefaultListModel) list.getModel()).setElementAt(value, list.getSelectedIndex()); } } } /** * 根据索引来添加数据 * * @param data 要添加的数据 * @param index 要添加的数据向的索引 */ public void addData(Object data, int index) { addData(data, index, false); } /** * 根据索引来添加数据 * * @param data 要添加的数据 * @param index 要添加的数据向的索引 * @param checkRepeat 是否检查名字重复 */ public void addData(Object data, int index, boolean checkRepeat) { if (contentViews == null || index < 0 || index > contentViews.length - 1) { return; } JList list = contentViews[index]; DefaultListModel model = (DefaultListModel) list.getModel(); if (data instanceof String) { model.addElement(createUnrepeatedName(model, (String) data, checkRepeat)); } if (checkRepeat) { // 将添加类型以外的其他类型都收起来 for (int i = 1, len = components.length; i < len; i++) { ((UIExtensionPane) components[i][0]).setExpand(false); } ((UIExtensionPane) components[index + 1][0]).setExpand(true); int selectedIndex = list.getModel().getSize() - 1; list.setSelectedIndex(selectedIndex); dealNewAddedDataIndex(((DefaultListModel) list.getModel()).elementAt(selectedIndex)); } } /** * 新添加的数据的序号 * @param data 数据 */ protected void dealNewAddedDataIndex(Object data){ } /** * 根据标题来添加数据 * * @param data 要添加的数据 * @param title 要添加数据的项的标题文字 */ public void addData(Object data, String title) { addData(data, title, false); } /** * 根据标题来添加数据 * * @param data 要添加的数据 * @param title 要添加数据的项的标题文字 * @param checkRepeat 是否检查名字重复 */ public void addData(Object data, String title, boolean checkRepeat) { int addIndex = ArrayUtils.indexOf(titles, title); if (addIndex != ArrayUtils.INDEX_NOT_FOUND) { addData(data, addIndex, checkRepeat); } } /** * 清除所有的数据 */ public void clearData() { for (JList list : contentViews) { ((DefaultListModel) list.getModel()).clear(); } } private String createUnrepeatedName(DefaultListModel model, String name, boolean checkRepeat) { if (!checkRepeat) { return name; } int count = model.getSize(); int extra = 1; String newName = name + (count + extra); boolean hasRepeated = false; do { hasRepeated = false; newName = name + (count + extra); for (int i = 0; i < count; i++) { if (ComparatorUtils.equals(model.getElementAt(i), newName)) { hasRepeated = true; extra++; } } } while (hasRepeated); return name + (count + extra); } /** * 判断该控件是否应该有编辑操作 * * @param list 列表组件 * @return 如果有编辑操作则需要显示相应的图标 */ private boolean hasEditOperation(JList list) { return true; } private DefaultListCellRenderer listCellRenderer = new DefaultListCellRenderer() { public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { JComponent c = (JComponent) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (!hasEditOperation(list)) { return c; } Border border = null; c.setBorder(border); UILabel editLabel = new UILabel(UIConstants.EDIT_ICON); UILabel deleteLabel = new UILabel(UIConstants.DELETE_ICON); JPanel editPane = GUICoreUtils.createFlowPane(new Component[]{editLabel, deleteLabel}, FlowLayout.LEFT, LayoutConstants.HGAP_LARGE); editPane.setBackground(isSelected ? c.getBackground() : null); editPane.setBorder(border); JPanel renderPane = GUICoreUtils.createBorderLayoutPane(c, BorderLayout.CENTER, editPane, BorderLayout.EAST); if (shouldFilter(value)) { renderPane.setPreferredSize(new Dimension(0, 0)); } return renderPane; } }; //事件发生的顺序是ListSelection、MousePressed、ListSelection、MouseReleased private ListSelectionListener listSelectionListener = new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { //在鼠标按下的时候的值改变事件,重置属性 if(e.getValueIsAdjusting()){ isPressOnDelete = false; } if(!isRespondToValueChange(e)){ return; } fireSelectionChangeListener(new ChangeEvent(e.getSource())); if (((JList) e.getSource()).getSelectedIndex() == -1) { return; } for (JList list : contentViews) { if (list.getSelectedIndex() != -1 && !ComparatorUtils.equals(list, e.getSource())) { try { list.setSelectedIndices(null); } catch (Exception ee) { } } } } }; /** * 是否响应list值改变 * @return 响应 */ protected boolean isRespondToValueChange(ListSelectionEvent e){ return true; } private boolean shouldFilter(Object value) { return !GeneralUtils.objectToString(value).toLowerCase().contains(searchTextFiled.getText().toLowerCase()); } private MouseListener mouseListener = new MouseAdapter() { /** * {@inheritDoc} */ @Override public void mousePressed(final MouseEvent e) { isPressOnDelete = false; final JList list = (JList) e.getSource(); Point point = e.getPoint(); final int index = list.locationToIndex(point); int width = list.getWidth(); if (hasEditOperation(list)) { // 删除按钮 if (point.x > width - (BUTTONWIDTH + LayoutConstants.HGAP_LARGE)) { BasicPane bp = new BasicPane() { protected String title4PopupWindow() { return ""; } }; isPressOnDelete = true; bp.setLayout(new BorderLayout()); bp.add(new BoldFontTextLabel(Inter.getLocText(new String[]{"Delete", "Chart-Map"}) + "?", SwingConstants.CENTER)); clearLastListSelection(list); final String selectedType = UIGroupExtensionPane.this.getSelectedType(); UIDialog dialog = bp.showUnsizedWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { public void doOk() { Object name = getSelectedObject(); ((DefaultListModel) list.getModel()).removeElementAt(index); MapSvgXMLHelper.getInstance().removeMapAttr(GeneralUtils.objectToString(name)); MapSvgXMLHelper.getInstance().removeCateNames(selectedType,GeneralUtils.objectToString(name)); fireDeleteListener(new ChangeEvent(e)); } }); dialog.setResizable(true); dialog.setSize(DIALOG_WIDTH, DIALOG_HEIGHT); dialog.setResizable(false); GUICoreUtils.centerWindow(dialog); dialog.setVisible(true); } // 编辑按钮 else if (point.x > width - (BUTTONWIDTH * 2 + 2 * LayoutConstants.HGAP_LARGE) && point.x < width - (BUTTONWIDTH + LayoutConstants.HGAP_LARGE)) { fireItemEditListener(new ChangeEvent(e)); } } } public void mouseReleased(MouseEvent e) { isPressOnDelete = false; } }; /** * 直接跨list点击删除按钮,要置之前list的选中项为空(因为删除操作不触发更新) * @param currentList 当前选中的list */ public void clearLastListSelection (JList currentList) { for (JList list : contentViews) { if (list.getSelectedIndex() != -1 && !ComparatorUtils.equals(list, currentList)) { try { list.setSelectedIndices(null); } catch (Exception e) { FRLogger.getLogger().error(e.getMessage()); } } } } /** * 是否点击在删除按钮上 * @return 是则返回true */ public boolean isPressOnDelete(){ return isPressOnDelete; } /** * 添加选中变化监听事件 * @param listener 监听 */ public void addSelectionChangeListener(ChangeListener listener) { selectionListeners.add(listener); } private void fireSelectionChangeListener(ChangeEvent e) { for (int i = selectionListeners.size(); i > 0; i--) { selectionListeners.get(i - 1).fireChanged(e); } } /** * 添加Item的监听事件 * @param listener 监听器 */ public void addItemEditListener(ChangeListener listener) { editListeners.add(listener); } private void fireItemEditListener(ChangeEvent e) { for (int i = editListeners.size(); i > 0; i--) { editListeners.get(i - 1).fireChanged(e); } } /** * 添加删除事件的监听事件 * @param listener 监听 */ public void addDeleteListener(ChangeListener listener) { deleteListeners.add(listener); } private void fireDeleteListener(ChangeEvent e) { for(int i = deleteListeners.size(); i > 0; i--) { deleteListeners.get(i - 1).fireChanged(e); } } public void setEnabled(boolean isEnabled){ super.setEnabled(isEnabled); if(searchTextFiled != null){ searchTextFiled.setEnabled(isEnabled); } if(this.components != null){ for(int i = 0; i < this.components.length; i++){ Component[] comp = this.components[i]; for(int j = 0; j < comp.length; j++){ comp[j].setEnabled(isEnabled); } } } } /** * 测试程序 * @param args 参数 */ public static void main(String[] args) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container c = f.getContentPane(); c.setBackground(Color.WHITE); c.setLayout(new BoxLayout(c, BoxLayout.Y_AXIS)); final UIGroupExtensionPane g = new UIGroupExtensionPane(new String[]{"title1", "title2", "title3"}); c.add(g, BorderLayout.CENTER); JPanel pp = new JPanel(new FlowLayout()); c.add(pp, BorderLayout.SOUTH); UIButton test = new UIButton("add1"); test.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { g.addData("test111", 0); } }); pp.add(test); UIButton test2 = new UIButton("add2"); test2.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { g.addData("test222", 1); } }); pp.add(test2); f.setSize(360, 500); f.setLocation(200, 100); f.setVisible(true); } } \ No newline at end of file diff --git a/designer_chart/src/com/fr/design/mainframe/MapEditPane.java b/designer_chart/src/com/fr/design/mainframe/MapEditPane.java index 2950a4d1f..4c137afb7 100644 --- a/designer_chart/src/com/fr/design/mainframe/MapEditPane.java +++ b/designer_chart/src/com/fr/design/mainframe/MapEditPane.java @@ -1,7 +1,7 @@ package com.fr.design.mainframe; -import com.fr.base.MapSvgAttr; -import com.fr.base.MapSvgXMLHelper; +import com.fr.chart.base.MapSvgAttr; +import com.fr.chart.base.MapSvgXMLHelper; import com.fr.chart.chartglyph.MapShapeValue; import com.fr.design.beans.BasicBeanPane; import com.fr.design.chart.series.PlotSeries.AbstrctMapAttrEditPane; From 3afae533473b7c75d72913d02cbe12dc1b9f556f Mon Sep 17 00:00:00 2001 From: mengao <283296419@qq.com> Date: Thu, 27 Jul 2017 11:57:19 +0800 Subject: [PATCH 22/50] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=8B=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E8=BF=94=E5=9B=9E=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/mainframe/chart/gui/type/AbstractChartTypePane.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer_chart/src/com/fr/design/mainframe/chart/gui/type/AbstractChartTypePane.java b/designer_chart/src/com/fr/design/mainframe/chart/gui/type/AbstractChartTypePane.java index 0afd0cd60..299d878d0 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/gui/type/AbstractChartTypePane.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/gui/type/AbstractChartTypePane.java @@ -133,7 +133,7 @@ public abstract class AbstractChartTypePane extends FurtherBasicBeanPane{ } //子类覆盖 - protected Plot getSelectedClonedPlot(){ + protected T getSelectedClonedPlot(){ return null; } From 65762d17f7e06eff0bcc4243c4dbd81ab3ff3260 Mon Sep 17 00:00:00 2001 From: mengao <283296419@qq.com> Date: Thu, 27 Jul 2017 14:26:06 +0800 Subject: [PATCH 23/50] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8D=A2=E8=A1=8C?= =?UTF-8?q?=E7=AC=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PlotSeries/MapGroupExtensionPane.java | 485 +++++++++++++++++- 1 file changed, 484 insertions(+), 1 deletion(-) diff --git a/designer_chart/src/com/fr/design/chart/series/PlotSeries/MapGroupExtensionPane.java b/designer_chart/src/com/fr/design/chart/series/PlotSeries/MapGroupExtensionPane.java index 36b0ec847..a1207717b 100644 --- a/designer_chart/src/com/fr/design/chart/series/PlotSeries/MapGroupExtensionPane.java +++ b/designer_chart/src/com/fr/design/chart/series/PlotSeries/MapGroupExtensionPane.java @@ -1 +1,484 @@ -package com.fr.design.chart.series.PlotSeries; import com.fr.base.*; import com.fr.chart.base.MapSvgAttr; import com.fr.chart.base.MapSvgXMLHelper; import com.fr.chart.chartattr.MapPlot; import com.fr.chart.chartglyph.MapShapeValue; import com.fr.design.DesignerEnvManager; import com.fr.design.constants.UIConstants; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.event.ChangeEvent; import com.fr.design.event.ChangeListener; import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserverListener; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerFrame; import com.fr.general.ComparatorUtils; import com.fr.general.FRLogger; import com.fr.general.Inter; import com.fr.stable.CoreConstants; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.stable.SvgProvider; import javax.swing.*; import javax.swing.event.ListSelectionEvent; import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseEvent; import java.awt.geom.RoundRectangle2D; import java.util.ArrayList; /** * Created by IntelliJ IDEA. * Author : Richer * Version: 7.0.3 * Date: 12-12-29 * Time: 下午2:41 */ public class MapGroupExtensionPane extends BasicPane implements UIObserver { private static final String[] TYPE_NAMES = new String[]{ Inter.getLocText("FR-Chart-World_Map"), Inter.getLocText("FR-Chart-State_Map"), Inter.getLocText("FR-Chart-Province_Map"), Inter.getLocText("FR-Chart-Custom_Map")}; private static final int WORD = 0; private static final int NATION = 1; private static final int STATE = 2; private static final int USER = 3; private static final int OFFSET_X = 800; private static final int OFFSET_Y = 200; private UIGroupExtensionPane groupExtensionPane; private UIButton addButton; private JPopupMenu popupMenu; private ArrayList changeListeners = new ArrayList(); private boolean hasPopulated = false; @Override protected String title4PopupWindow() { return "Map"; } public MapGroupExtensionPane() { setLayout(new BorderLayout()); groupExtensionPane = new UIGroupExtensionPane(TYPE_NAMES){ /** * 新添加的数据的序号 * @param data 数据 */ protected void dealNewAddedDataIndex(Object data){ String newName = (String)data; MapSvgXMLHelper helper = MapSvgXMLHelper.getInstance(); if(helper.getNewMapAttr(newName) != null){ return; } MapSvgAttr attr = new MapSvgAttr(); attr.setFilePath(MapSvgXMLHelper.customMapPath() + CoreConstants.SEPARATOR + newName + ".svg"); helper.addNewSvgMaps(attr.getName(), attr); } /** * 一次鼠标的点击会有两次事件响应(按下和释放)。前者的事件属性中getValueIsAdjusting()=true,后者是false。 * 是否响应list值改变 * @return 鼠标按下时不响应,先响应mousePress事件,在鼠标释放是再响应list值改编的事件,并且点击删除不触发更新,并且populate后触发更新 */ protected boolean isRespondToValueChange(ListSelectionEvent e){ return !e.getValueIsAdjusting() && !this.isPressOnDelete() && hasPopulated; } }; groupExtensionPane.addSelectionChangeListener(new ChangeListener() { @Override public void fireChanged(ChangeEvent event) { fireStateChange(); } }); groupExtensionPane.addItemEditListener(new ChangeListener() { @Override public void fireChanged(ChangeEvent event) { doEdit(event); } }); groupExtensionPane.addDeleteListener(new ChangeListener() { @Override public void fireChanged(ChangeEvent event) { //这么写有点问题 String oldName = Utils.objectToString(groupExtensionPane.getSelectedObject()); saveMapInfo(oldName); } }); setPreferredSize(new Dimension(400, 210)); add(groupExtensionPane, BorderLayout.CENTER); addButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/add.png")) { @Override protected void paintBorder(Graphics g) { Graphics2D g2d = (Graphics2D) g; g2d.setStroke(UIConstants.BS); Shape shape = new RoundRectangle2D.Float(0.5f, 0.5f, getWidth() - 1, getHeight() - 1, UIConstants.ARC, UIConstants.ARC); g2d.setColor(UIConstants.LINE_COLOR); g2d.draw(shape); } }; addButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { popupMenu.show(MapGroupExtensionPane.this, addButton.getX() + 1, addButton.getY() + addButton.getHeight()); } }); add(addButton, BorderLayout.SOUTH); initPopupMenu(); } private void initPopupMenu() { popupMenu = new JPopupMenu() { @Override public Dimension getPreferredSize() { Dimension dimension = new Dimension(); dimension.height = super.getPreferredSize().height; dimension.width = addButton.getWidth() - 2; return dimension; } }; JMenuItem worldMap = new JMenuItem(TYPE_NAMES[WORD]); popupMenu.add(worldMap); worldMap.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { groupExtensionPane.addData(TYPE_NAMES[WORD], TYPE_NAMES[WORD], true); } }); JMenuItem countMap = new JMenuItem(TYPE_NAMES[NATION]); popupMenu.add(countMap); countMap.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { groupExtensionPane.addData(TYPE_NAMES[NATION], TYPE_NAMES[NATION], true); } }); JMenuItem proMap = new JMenuItem(TYPE_NAMES[STATE]); popupMenu.add(proMap); proMap.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { groupExtensionPane.addData(TYPE_NAMES[STATE], TYPE_NAMES[STATE], true); } }); JMenuItem menu = new JMenuItem(TYPE_NAMES[USER]); popupMenu.add(menu); menu.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { groupExtensionPane.addData(TYPE_NAMES[USER], TYPE_NAMES[USER], true); } }); } private void doEdit(ChangeEvent e) { MouseEvent event = (MouseEvent) e.getSource(); JPopupMenu editPopMenu = new JPopupMenu(); final String oldName = Utils.objectToString(groupExtensionPane.getSelectedObject()); editPopMenu.add(createAreaItem(oldName)); editPopMenu.add(createMarkerItem(oldName)); editPopMenu.add(createLayerItem(oldName)); editPopMenu.add(createRenameItem()); editPopMenu.show(MapGroupExtensionPane.this, event.getXOnScreen() - OFFSET_X, event.getYOnScreen() - OFFSET_Y); } private void mapCheckBeforeEdit(String name){ if(MapSvgXMLHelper.getInstance().containsMapName(name) || MapSvgXMLHelper.getInstance().getNewMapAttr(name)!=null){ return; } MapSvgAttr attr = new MapSvgAttr(); attr.setFilePath(MapSvgXMLHelper.customMapPath() + CoreConstants.SEPARATOR + name + ".svg"); MapSvgXMLHelper.getInstance().addNewSvgMaps(name,attr); } private JMenuItem createAreaItem(final String oldName) { JMenuItem editFileItem = new JMenuItem(Inter.getLocText(new String[]{"Edit", "Image", "Filed"})); editFileItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { final MapCustomPane image = new MapCustomPane(); image.setImageSelectType(MapShapeValue.AREA); image.populateBean(oldName); image.setTypeNameAndMapName(groupExtensionPane.getSelectedType(), Utils.objectToString(groupExtensionPane.getSelectedObject())); mapCheckBeforeEdit(oldName); final Image oldImage = getMapImage(oldName); BasicDialog dialog = image.showMediumWindow(SwingUtilities.getWindowAncestor(MapGroupExtensionPane.this), new DialogActionAdapter() { public void doOk() { image.updateBean(); // 比较两个前后的名字是否相同, 是图片 如果图片不同, 则直接比较 Image newImage = getMapImage(oldName); if(!ComparatorUtils.equals(oldImage, newImage)) { fireStateChange(); } //versionID递增 MapSvgAttr old = MapSvgXMLHelper.getInstance().getMapAttr(oldName); if(old != null) { old.addVersionID(); } saveMapInfo(oldName); refresh(); } }); dialog.setVisible(true); } }); return editFileItem; } //根据地图的名字返回地图的图片 private Image getMapImage(String mapName) { if (MapSvgXMLHelper.getInstance().containsMapName(mapName)) { MapSvgAttr mapAttr = MapSvgXMLHelper.getInstance().getMapAttr(mapName); if(mapAttr == null) { return null; } return mapAttr.getMapImage(); } return null; } private JMenuItem createMarkerItem(final String oldName) { JMenuItem editMarkerItem = new JMenuItem(Inter.getLocText(new String[]{"Edit", "Image", "Marker"})); editMarkerItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { final MapCustomPane image = new MapCustomPane(); image.setImageSelectType(MapShapeValue.POINT); image.populateBean(oldName); mapCheckBeforeEdit(oldName); final Image oldImage = getMapImage(oldName); BasicDialog dialog = image.showMediumWindow(SwingUtilities.getWindowAncestor(image), new DialogActionAdapter() { public void doOk() { image.updateBean(); Image newImage = getMapImage(oldName); if(!ComparatorUtils.equals(oldImage, newImage)) { fireStateChange(); } //versionID递增 MapSvgAttr old = MapSvgXMLHelper.getInstance().getMapAttr(oldName); if(old != null) { old.addVersionID(); } saveMapInfo(oldName); refresh(); } }); dialog.setVisible(true); } }); return editMarkerItem; } private JMenuItem createLayerItem(final String oldName) { JMenuItem corrItem = new JMenuItem(Inter.getLocText(new String[]{"Filed", "Corresponding_Fields"})); corrItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { final MapDefiAreaNamePane namedPane = new MapDefiAreaNamePane(); namedPane.populateBean(oldName); mapCheckBeforeEdit(oldName); BasicDialog dialog = namedPane.showMediumWindow(SwingUtilities.getWindowAncestor(namedPane), new DialogActionAdapter() { public void doOk() { namedPane.updateBean();// 地图的名称 value对应情况 MapSvgAttr old = MapSvgXMLHelper.getInstance().getMapAttr(oldName); if(old != null) { old.addVersionID(); } saveMapInfo(oldName); } }); dialog.setVisible(true); refresh(); } }); return corrItem; } private void showRenameWaring(String newName){ JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), "\"" + newName + "\"" + Inter.getLocText("Utils-has_been_existed") + "!", Inter.getLocText("FR-Designer_Alert"), JOptionPane.WARNING_MESSAGE); } private JMenuItem createRenameItem() { JMenuItem renameItem = new JMenuItem(Inter.getLocText("FR-Chart-Map_Rename")); renameItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String newName = JOptionPane.showInputDialog(DesignerContext.getDesignerFrame().getContentPane(), Inter.getLocText("FR-Chart-Map_Rename"), groupExtensionPane.getSelectedObject()); if (StringUtils.isNotBlank(newName)) { String oldName = Utils.objectToString(groupExtensionPane.getSelectedObject()); if(ComparatorUtils.equals(oldName, newName)){ return; } //本地在看看临时的helper里面有没有 if(MapSvgXMLHelper.getInstance().getNewMapAttr(newName) != null){ showRenameWaring(newName); return; } try{//提醒名字已存在 if(FRContext.getCurrentEnv().fileExists(StableUtils.pathJoin( new String[]{MapSvgXMLHelper.relativeDefaultMapPath(),newName+SvgProvider.EXTENSION}))){ showRenameWaring(newName); return; } if(FRContext.getCurrentEnv().fileExists(StableUtils.pathJoin( new String[]{MapSvgXMLHelper.relativeCustomMapPath(), newName + SvgProvider.EXTENSION}))){ showRenameWaring(newName); return; } MapSvgAttr editingAttr = MapSvgXMLHelper.getInstance().getMapAttr(oldName); if(editingAttr == null){ editingAttr = MapSvgXMLHelper.getInstance().getNewMapAttr(oldName); } if( editingAttr == null) { return; } editingAttr.renameMap(newName); groupExtensionPane.setValueAtCurrentSelectIndex(newName); fireStateChange(); saveMapInfo(newName); FRContext.getCurrentEnv().deleteFile( StableUtils.pathJoin(new String[]{MapSvgXMLHelper.relativeDefaultMapPath(),oldName+SvgProvider.EXTENSION})); FRContext.getCurrentEnv().deleteFile( StableUtils.pathJoin(new String[]{MapSvgXMLHelper.relativeCustomMapPath(),oldName+SvgProvider.EXTENSION})); refresh(); }catch (Exception exp){ FRLogger.getLogger().error(exp.getMessage()); } } } }); return renameItem; } private void refresh() { this.validate(); this.repaint(); DesignerFrame frame = DesignerContext.getDesignerFrame(); if(frame != null) { frame.repaint();//kunsnat: 图表属性没变, 只是读取时 内容变化. } } //保存修改过的地图信息 private void saveMapInfo(final String mapName) { SwingWorker worker = new SwingWorker() { @Override protected Integer doInBackground() throws Exception { MapSvgAttr attr = MapSvgXMLHelper.getInstance().getMapAttr(mapName);// 只有在编辑地图时才需要储存相关数据 @kuns if(attr != null){ attr.writeBack(mapName); } return 0; } @Override protected void done() { FRLogger.getLogger().info(Inter.getLocText("FR-Chart-Map_Saved")); // 地图已经保存. } }; worker.execute(); DesignerEnvManager.addWorkers(worker); } private void fireStateChange() { for (int i = changeListeners.size(); i > 0; i--) { changeListeners.get(i - 1).stateChanged(new javax.swing.event.ChangeEvent(this)); } } /** * 更新地图属性 * @return 返回地图名称. */ public String updateBean(MapPlot plot) { if(!hasPopulated){ this.populateBean(plot); hasPopulated = true; } MapHelper helper = plot.isSvgMap() ? MapSvgXMLHelper.getInstance() : MapXMLHelper.getInstance(); helper.clearCateNames(); for (String type : TYPE_NAMES) { Object[] datas = groupExtensionPane.getData(type); for (Object name : datas) { helper.addCateNames(type, name); } } return Utils.objectToString(groupExtensionPane.getSelectedObject()); } /** * 更新地图名称 * @param mapPlot 地图 */ public void populateBean(MapPlot mapPlot) { hasPopulated = false; groupExtensionPane.clearData(); for (String type : TYPE_NAMES) { MapHelper helper = mapPlot.isSvgMap() ? MapSvgXMLHelper.getInstance() : MapXMLHelper.getInstance(); java.util.List list = helper.getNamesListWithCateName(type); for (Object name : list) { groupExtensionPane.addData(name, type); } } groupExtensionPane.setSelectedObject(mapPlot.getMapName()); hasPopulated = true; } /** * 给组件登记一个观察者监听事件 * * @param listener 观察者监听事件 */ public void registerChangeListener(final UIObserverListener listener) { changeListeners.add(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent e) { listener.doChange(); } }); } /** * 组件是否需要响应添加的观察者事件 * * @return 如果需要响应观察者事件则返回true,否则返回false */ public boolean shouldResponseChangeListener() { return true; } public void setEnabled(boolean isEnabled){ super.setEnabled(isEnabled); addButton.setEnabled(isEnabled); popupMenu.setEnabled(isEnabled); groupExtensionPane.setEnabled(isEnabled); } } \ No newline at end of file +package com.fr.design.chart.series.PlotSeries; + +import com.fr.base.*; +import com.fr.chart.base.MapSvgAttr; +import com.fr.chart.base.MapSvgXMLHelper; +import com.fr.chart.chartattr.MapPlot; +import com.fr.chart.chartglyph.MapShapeValue; +import com.fr.design.DesignerEnvManager; +import com.fr.design.constants.UIConstants; +import com.fr.design.dialog.BasicDialog; +import com.fr.design.dialog.BasicPane; +import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.event.ChangeEvent; +import com.fr.design.event.ChangeListener; +import com.fr.design.event.UIObserver; +import com.fr.design.event.UIObserverListener; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.DesignerFrame; +import com.fr.general.ComparatorUtils; +import com.fr.general.FRLogger; +import com.fr.general.Inter; +import com.fr.stable.CoreConstants; +import com.fr.stable.StableUtils; +import com.fr.stable.StringUtils; +import com.fr.stable.SvgProvider; + +import javax.swing.*; +import javax.swing.event.ListSelectionEvent; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseEvent; +import java.awt.geom.RoundRectangle2D; +import java.util.ArrayList; + +/** + * Created by IntelliJ IDEA. + * Author : Richer + * Version: 7.0.3 + * Date: 12-12-29 + * Time: 下午2:41 + */ +public class MapGroupExtensionPane extends BasicPane implements UIObserver { + private static final String[] TYPE_NAMES = new String[]{ + Inter.getLocText("FR-Chart-World_Map"), + Inter.getLocText("FR-Chart-State_Map"), + Inter.getLocText("FR-Chart-Province_Map"), + Inter.getLocText("FR-Chart-Custom_Map")}; + private static final int WORD = 0; + private static final int NATION = 1; + private static final int STATE = 2; + private static final int USER = 3; + private static final int OFFSET_X = 800; + private static final int OFFSET_Y = 200; + + private UIGroupExtensionPane groupExtensionPane; + private UIButton addButton; + private JPopupMenu popupMenu; + private ArrayList changeListeners = new ArrayList(); + private boolean hasPopulated = false; + + @Override + protected String title4PopupWindow() { + return "Map"; + } + + public MapGroupExtensionPane() { + setLayout(new BorderLayout()); + groupExtensionPane = new UIGroupExtensionPane(TYPE_NAMES){ + + /** + * 新添加的数据的序号 + * @param data 数据 + */ + protected void dealNewAddedDataIndex(Object data){ + String newName = (String)data; + MapSvgXMLHelper helper = MapSvgXMLHelper.getInstance(); + if(helper.getNewMapAttr(newName) != null){ + return; + } + MapSvgAttr attr = new MapSvgAttr(); + attr.setFilePath(MapSvgXMLHelper.customMapPath() + CoreConstants.SEPARATOR + newName + ".svg"); + helper.addNewSvgMaps(attr.getName(), attr); + } + + + /** + * 一次鼠标的点击会有两次事件响应(按下和释放)。前者的事件属性中getValueIsAdjusting()=true,后者是false。 + * 是否响应list值改变 + * @return 鼠标按下时不响应,先响应mousePress事件,在鼠标释放是再响应list值改编的事件,并且点击删除不触发更新,并且populate后触发更新 + */ + protected boolean isRespondToValueChange(ListSelectionEvent e){ + return !e.getValueIsAdjusting() && !this.isPressOnDelete() && hasPopulated; + } + }; + groupExtensionPane.addSelectionChangeListener(new ChangeListener() { + @Override + public void fireChanged(ChangeEvent event) { + fireStateChange(); + } + }); + groupExtensionPane.addItemEditListener(new ChangeListener() { + @Override + public void fireChanged(ChangeEvent event) { + doEdit(event); + } + }); + groupExtensionPane.addDeleteListener(new ChangeListener() { + @Override + public void fireChanged(ChangeEvent event) { + //这么写有点问题 + String oldName = Utils.objectToString(groupExtensionPane.getSelectedObject()); + saveMapInfo(oldName); + } + }); + setPreferredSize(new Dimension(400, 210)); + add(groupExtensionPane, BorderLayout.CENTER); + + addButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/add.png")) { + @Override + protected void paintBorder(Graphics g) { + Graphics2D g2d = (Graphics2D) g; + g2d.setStroke(UIConstants.BS); + Shape shape = new RoundRectangle2D.Float(0.5f, 0.5f, getWidth() - 1, getHeight() - 1, UIConstants.ARC, UIConstants.ARC); + g2d.setColor(UIConstants.LINE_COLOR); + g2d.draw(shape); + } + }; + addButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + popupMenu.show(MapGroupExtensionPane.this, addButton.getX() + 1, addButton.getY() + addButton.getHeight()); + } + }); + add(addButton, BorderLayout.SOUTH); + initPopupMenu(); + } + + private void initPopupMenu() { + popupMenu = new JPopupMenu() { + @Override + public Dimension getPreferredSize() { + Dimension dimension = new Dimension(); + dimension.height = super.getPreferredSize().height; + dimension.width = addButton.getWidth() - 2; + return dimension; + } + }; + JMenuItem worldMap = new JMenuItem(TYPE_NAMES[WORD]); + popupMenu.add(worldMap); + worldMap.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + groupExtensionPane.addData(TYPE_NAMES[WORD], TYPE_NAMES[WORD], true); + } + }); + + JMenuItem countMap = new JMenuItem(TYPE_NAMES[NATION]); + popupMenu.add(countMap); + countMap.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + groupExtensionPane.addData(TYPE_NAMES[NATION], + TYPE_NAMES[NATION], true); + } + }); + + JMenuItem proMap = new JMenuItem(TYPE_NAMES[STATE]); + popupMenu.add(proMap); + proMap.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + groupExtensionPane.addData(TYPE_NAMES[STATE], + TYPE_NAMES[STATE], true); + } + }); + + JMenuItem menu = new JMenuItem(TYPE_NAMES[USER]); + popupMenu.add(menu); + menu.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + groupExtensionPane.addData(TYPE_NAMES[USER], + TYPE_NAMES[USER], true); + } + }); + } + + private void doEdit(ChangeEvent e) { + MouseEvent event = (MouseEvent) e.getSource(); + JPopupMenu editPopMenu = new JPopupMenu(); + + final String oldName = Utils.objectToString(groupExtensionPane.getSelectedObject()); + editPopMenu.add(createAreaItem(oldName)); + editPopMenu.add(createMarkerItem(oldName)); + editPopMenu.add(createLayerItem(oldName)); + editPopMenu.add(createRenameItem()); + + editPopMenu.show(MapGroupExtensionPane.this, event.getXOnScreen() - OFFSET_X, event.getYOnScreen() - OFFSET_Y); + } + + private void mapCheckBeforeEdit(String name){ + if(MapSvgXMLHelper.getInstance().containsMapName(name) || MapSvgXMLHelper.getInstance().getNewMapAttr(name)!=null){ + return; + } + MapSvgAttr attr = new MapSvgAttr(); + attr.setFilePath(MapSvgXMLHelper.customMapPath() + CoreConstants.SEPARATOR + name + ".svg"); + MapSvgXMLHelper.getInstance().addNewSvgMaps(name,attr); + } + + private JMenuItem createAreaItem(final String oldName) { + JMenuItem editFileItem = new JMenuItem(Inter.getLocText(new String[]{"Edit", "Image", "Filed"})); + editFileItem.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + final MapCustomPane image = new MapCustomPane(); + image.setImageSelectType(MapShapeValue.AREA); + image.populateBean(oldName); + image.setTypeNameAndMapName(groupExtensionPane.getSelectedType(), Utils.objectToString(groupExtensionPane.getSelectedObject())); + mapCheckBeforeEdit(oldName); + final Image oldImage = getMapImage(oldName); + BasicDialog dialog = image.showMediumWindow(SwingUtilities.getWindowAncestor(MapGroupExtensionPane.this), new DialogActionAdapter() { + public void doOk() { + image.updateBean(); // 比较两个前后的名字是否相同, 是图片 如果图片不同, 则直接比较 + + Image newImage = getMapImage(oldName); + if(!ComparatorUtils.equals(oldImage, newImage)) { + fireStateChange(); + } + + //versionID递增 + MapSvgAttr old = MapSvgXMLHelper.getInstance().getMapAttr(oldName); + if(old != null) { + old.addVersionID(); + } + + saveMapInfo(oldName); + refresh(); + } + }); + dialog.setVisible(true); + } + }); + return editFileItem; + } + + //根据地图的名字返回地图的图片 + private Image getMapImage(String mapName) { + if (MapSvgXMLHelper.getInstance().containsMapName(mapName)) { + MapSvgAttr mapAttr = MapSvgXMLHelper.getInstance().getMapAttr(mapName); + if(mapAttr == null) { + return null; + } + return mapAttr.getMapImage(); + } + + return null; + } + + private JMenuItem createMarkerItem(final String oldName) { + JMenuItem editMarkerItem = new JMenuItem(Inter.getLocText(new String[]{"Edit", "Image", "Marker"})); + editMarkerItem.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + final MapCustomPane image = new MapCustomPane(); + image.setImageSelectType(MapShapeValue.POINT); + image.populateBean(oldName); + mapCheckBeforeEdit(oldName); + final Image oldImage = getMapImage(oldName); + BasicDialog dialog = image.showMediumWindow(SwingUtilities.getWindowAncestor(image), new DialogActionAdapter() { + public void doOk() { + image.updateBean(); + + Image newImage = getMapImage(oldName); + if(!ComparatorUtils.equals(oldImage, newImage)) { + fireStateChange(); + } + + //versionID递增 + MapSvgAttr old = MapSvgXMLHelper.getInstance().getMapAttr(oldName); + if(old != null) { + old.addVersionID(); + } + + saveMapInfo(oldName); + refresh(); + } + }); + dialog.setVisible(true); + } + }); + return editMarkerItem; + } + + private JMenuItem createLayerItem(final String oldName) { + JMenuItem corrItem = new JMenuItem(Inter.getLocText(new String[]{"Filed", "Corresponding_Fields"})); + corrItem.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + final MapDefiAreaNamePane namedPane = new MapDefiAreaNamePane(); + namedPane.populateBean(oldName); + mapCheckBeforeEdit(oldName); + BasicDialog dialog = namedPane.showMediumWindow(SwingUtilities.getWindowAncestor(namedPane), new DialogActionAdapter() { + public void doOk() { + namedPane.updateBean();// 地图的名称 value对应情况 + + MapSvgAttr old = MapSvgXMLHelper.getInstance().getMapAttr(oldName); + if(old != null) { + old.addVersionID(); + } + + saveMapInfo(oldName); + } + }); + dialog.setVisible(true); + refresh(); + } + }); + + return corrItem; + } + + private void showRenameWaring(String newName){ + JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), "\"" + newName + "\"" + Inter.getLocText("Utils-has_been_existed") + + "!", Inter.getLocText("FR-Designer_Alert"), JOptionPane.WARNING_MESSAGE); + } + + private JMenuItem createRenameItem() { + JMenuItem renameItem = new JMenuItem(Inter.getLocText("FR-Chart-Map_Rename")); + renameItem.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + String newName = JOptionPane.showInputDialog(DesignerContext.getDesignerFrame().getContentPane(), + Inter.getLocText("FR-Chart-Map_Rename"), groupExtensionPane.getSelectedObject()); + if (StringUtils.isNotBlank(newName)) { + String oldName = Utils.objectToString(groupExtensionPane.getSelectedObject()); + if(ComparatorUtils.equals(oldName, newName)){ + return; + } + //本地在看看临时的helper里面有没有 + if(MapSvgXMLHelper.getInstance().getNewMapAttr(newName) != null){ + showRenameWaring(newName); + return; + } + try{//提醒名字已存在 + if(FRContext.getCurrentEnv().fileExists(StableUtils.pathJoin( + new String[]{MapSvgXMLHelper.relativeDefaultMapPath(),newName+SvgProvider.EXTENSION}))){ + showRenameWaring(newName); + return; + } + if(FRContext.getCurrentEnv().fileExists(StableUtils.pathJoin( + new String[]{MapSvgXMLHelper.relativeCustomMapPath(), newName + SvgProvider.EXTENSION}))){ + showRenameWaring(newName); + return; + } + MapSvgAttr editingAttr = MapSvgXMLHelper.getInstance().getMapAttr(oldName); + if(editingAttr == null){ + editingAttr = MapSvgXMLHelper.getInstance().getNewMapAttr(oldName); + } + if( editingAttr == null) { + return; + } + editingAttr.renameMap(newName); + groupExtensionPane.setValueAtCurrentSelectIndex(newName); + fireStateChange(); + saveMapInfo(newName); + FRContext.getCurrentEnv().deleteFile( + StableUtils.pathJoin(new String[]{MapSvgXMLHelper.relativeDefaultMapPath(),oldName+SvgProvider.EXTENSION})); + FRContext.getCurrentEnv().deleteFile( + StableUtils.pathJoin(new String[]{MapSvgXMLHelper.relativeCustomMapPath(),oldName+SvgProvider.EXTENSION})); + refresh(); + }catch (Exception exp){ + FRLogger.getLogger().error(exp.getMessage()); + } + } + } + }); + return renameItem; + } + + private void refresh() { + this.validate(); + this.repaint(); + + DesignerFrame frame = DesignerContext.getDesignerFrame(); + if(frame != null) { + frame.repaint();//kunsnat: 图表属性没变, 只是读取时 内容变化. + } + } + + //保存修改过的地图信息 + private void saveMapInfo(final String mapName) { + SwingWorker worker = new SwingWorker() { + @Override + protected Integer doInBackground() throws Exception { + MapSvgAttr attr = MapSvgXMLHelper.getInstance().getMapAttr(mapName);// 只有在编辑地图时才需要储存相关数据 @kuns + if(attr != null){ + attr.writeBack(mapName); + } + return 0; + } + + @Override + protected void done() { + FRLogger.getLogger().info(Inter.getLocText("FR-Chart-Map_Saved")); // 地图已经保存. + } + + }; + worker.execute(); + DesignerEnvManager.addWorkers(worker); + } + + private void fireStateChange() { + for (int i = changeListeners.size(); i > 0; i--) { + changeListeners.get(i - 1).stateChanged(new javax.swing.event.ChangeEvent(this)); + } + } + + /** + * 更新地图属性 + * @return 返回地图名称. + */ + public String updateBean(MapPlot plot) { + if(!hasPopulated){ + this.populateBean(plot); + hasPopulated = true; + } + + MapHelper helper = plot.isSvgMap() ? MapSvgXMLHelper.getInstance() : MapXMLHelper.getInstance(); + + helper.clearCateNames(); + for (String type : TYPE_NAMES) { + Object[] datas = groupExtensionPane.getData(type); + for (Object name : datas) { + helper.addCateNames(type, name); + } + } + + return Utils.objectToString(groupExtensionPane.getSelectedObject()); + } + + /** + * 更新地图名称 + * @param mapPlot 地图 + */ + public void populateBean(MapPlot mapPlot) { + hasPopulated = false; + groupExtensionPane.clearData(); + + for (String type : TYPE_NAMES) { + MapHelper helper = mapPlot.isSvgMap() ? MapSvgXMLHelper.getInstance() : MapXMLHelper.getInstance(); + java.util.List list = helper.getNamesListWithCateName(type); + for (Object name : list) { + groupExtensionPane.addData(name, type); + } + } + + groupExtensionPane.setSelectedObject(mapPlot.getMapName()); + + hasPopulated = true; + } + + /** + * 给组件登记一个观察者监听事件 + * + * @param listener 观察者监听事件 + */ + public void registerChangeListener(final UIObserverListener listener) { + changeListeners.add(new javax.swing.event.ChangeListener() { + public void stateChanged(javax.swing.event.ChangeEvent e) { + listener.doChange(); + } + }); + } + + /** + * 组件是否需要响应添加的观察者事件 + * + * @return 如果需要响应观察者事件则返回true,否则返回false + */ + public boolean shouldResponseChangeListener() { + return true; + } + + public void setEnabled(boolean isEnabled){ + super.setEnabled(isEnabled); + addButton.setEnabled(isEnabled); + popupMenu.setEnabled(isEnabled); + groupExtensionPane.setEnabled(isEnabled); + } +} \ No newline at end of file From 94a59be635ad7592e3a31f0724ade9345c47c834 Mon Sep 17 00:00:00 2001 From: neil <459208047@qq.com> Date: Tue, 1 Aug 2017 11:43:27 +0800 Subject: [PATCH 24/50] =?UTF-8?q?REPORT-3406=20win10=E5=86=85=E5=AD=98?= =?UTF-8?q?=E4=B8=8D=E8=B6=B3=E6=97=B6=E6=89=BE=E4=B8=8D=E5=88=B0=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E6=B5=8F=E8=A7=88=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/start/StartServer.java | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/designer_base/src/com/fr/start/StartServer.java b/designer_base/src/com/fr/start/StartServer.java index e21beef7b..7c5b77f52 100644 --- a/designer_base/src/com/fr/start/StartServer.java +++ b/designer_base/src/com/fr/start/StartServer.java @@ -14,10 +14,7 @@ import com.fr.env.SignIn; import com.fr.general.ComparatorUtils; import com.fr.general.GeneralContext; import com.fr.general.Inter; -import com.fr.stable.EnvChangedListener; -import com.fr.stable.ProductConstants; -import com.fr.stable.StableUtils; -import com.fr.stable.StringUtils; +import com.fr.stable.*; import com.fr.stable.project.ProjectConstants; import com.fr.start.server.JettyHost; @@ -154,8 +151,7 @@ public class StartServer { Desktop.getDesktop().browse(new URI(uri)); } catch (IOException e) { - JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer_Set_default_browser")); - FRContext.getLogger().errorWithServerLevel(e.getMessage(), e); + startBrowserFromCommand(uri, e); } catch (URISyntaxException e) { FRContext.getLogger().errorWithServerLevel(e.getMessage(), e); } catch (Exception e) { @@ -164,6 +160,20 @@ public class StartServer { } } + private static void startBrowserFromCommand(String uri, IOException e) { + if (OperatingSystem.isWindows()) { + try { + // win10 内存用到到80%左右的时候, Desktop.browser经常提示"存储空间不足, 无法处理改命令", 用rundll32可以打开. + Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + uri); + } catch (IOException ee) { + JOptionPane.showMessageDialog(null, Inter.getLocText("FR-Designer_Set_default_browser")); + FRContext.getLogger().errorWithServerLevel(e.getMessage(), e); + } + } else { + FRContext.getLogger().errorWithServerLevel(e.getMessage(), e); + } + } + private static class InformationPane extends BasicPane { private static final long serialVersionUID = 1L; From d344e92e8baa91c94b70e374dfd324cb74e31233 Mon Sep 17 00:00:00 2001 From: neil <459208047@qq.com> Date: Tue, 1 Aug 2017 15:30:28 +0800 Subject: [PATCH 25/50] 1 --- .../editor/editor/ColumnSelectedEditor.java | 16 +-- ...egoryPlotMoreCateTableDataContentPane.java | 130 +++++++++--------- 2 files changed, 73 insertions(+), 73 deletions(-) diff --git a/designer_base/src/com/fr/design/editor/editor/ColumnSelectedEditor.java b/designer_base/src/com/fr/design/editor/editor/ColumnSelectedEditor.java index d8ae98bbc..71014d4c8 100644 --- a/designer_base/src/com/fr/design/editor/editor/ColumnSelectedEditor.java +++ b/designer_base/src/com/fr/design/editor/editor/ColumnSelectedEditor.java @@ -1,7 +1,7 @@ package com.fr.design.editor.editor; -import com.fr.data.SimpleDSColumn; import com.fr.design.data.DesignTableDataManager; +import com.fr.data.SimpleDSColumn; import com.fr.design.data.datapane.TableDataComboBox; import com.fr.design.data.tabledata.wrapper.TableDataWrapper; import com.fr.design.gui.icombobox.UIComboBox; @@ -36,13 +36,13 @@ public class ColumnSelectedEditor extends Editor { @Override public void itemStateChanged(ItemEvent e) { - TableDataWrapper tableDataWrapper = tableDataComboBox.getSelectedItem(); - if (tableDataWrapper == null) { - return; - } - //这边需要重新初始化columnNames, 否则nameList长度和columnNames长度不同导致出錯。 - List nameList = tableDataWrapper.calculateColumnNameList(); - columnNames = new String[nameList.size()]; + TableDataWrapper tableDataWrapper = tableDataComboBox.getSelectedItem(); + if (tableDataWrapper == null) { + return; + } + //这边需要重新初始化columnNames, 否则nameList长度和columnNames长度不同导致出錯。 + List nameList = tableDataWrapper.calculateColumnNameList(); + columnNames = new String[nameList.size()]; columnNames = tableDataComboBox.getSelectedItem().calculateColumnNameList().toArray(columnNames); columnNameComboBox.removeAllItems(); for (int i = 0; i < columnNames.length; i++) { diff --git a/designer_chart/src/com/fr/design/mainframe/chart/gui/data/table/CategoryPlotMoreCateTableDataContentPane.java b/designer_chart/src/com/fr/design/mainframe/chart/gui/data/table/CategoryPlotMoreCateTableDataContentPane.java index 0b1909f98..aae7e3540 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/gui/data/table/CategoryPlotMoreCateTableDataContentPane.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/gui/data/table/CategoryPlotMoreCateTableDataContentPane.java @@ -37,10 +37,10 @@ public class CategoryPlotMoreCateTableDataContentPane extends CategoryPlotTableD private static final int COMBOX_HEIGHT = 20; private JPanel boxPane; - + private ArrayList boxList = new ArrayList(); private UIButton addButton; - + private UIObserverListener uiobListener = null; public List getBoxList() { @@ -50,31 +50,31 @@ public class CategoryPlotMoreCateTableDataContentPane extends CategoryPlotTableD public CategoryPlotMoreCateTableDataContentPane() { // do nothing } - + public CategoryPlotMoreCateTableDataContentPane(ChartDataPane parent) { categoryCombox = new UIComboBox(); categoryCombox.setPreferredSize(new Dimension(100,20)); - + JPanel categoryPane = new JPanel(new BorderLayout(4,0)); categoryPane.setBorder(BorderFactory.createMatteBorder(0, 0, 6, 1, getBackground())); - UILabel categoryLabel = new BoldFontTextLabel(Inter.getLocText("FR-Chart-Category_Name") + ":", SwingConstants.RIGHT) ; - categoryLabel.setPreferredSize(new Dimension(75,20)); - - addButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/add.png")); - addButton.setPreferredSize(new Dimension(20, 20)); - - categoryPane.add(GUICoreUtils.createBorderLayoutPane(new Component[]{categoryCombox, addButton,null,categoryLabel,null})); - - boxPane = new JPanel(); - boxPane.setLayout(new BoxLayout(boxPane, BoxLayout.Y_AXIS)); - - categoryPane.add(boxPane, BorderLayout.SOUTH); - + UILabel categoryLabel = new BoldFontTextLabel(Inter.getLocText("FR-Chart-Category_Name") + ":", SwingConstants.RIGHT) ; + categoryLabel.setPreferredSize(new Dimension(75,20)); + + addButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/add.png")); + addButton.setPreferredSize(new Dimension(20, 20)); + + categoryPane.add(GUICoreUtils.createBorderLayoutPane(new Component[]{categoryCombox, addButton,null,categoryLabel,null})); + + boxPane = new JPanel(); + boxPane.setLayout(new BoxLayout(boxPane, BoxLayout.Y_AXIS)); + + categoryPane.add(boxPane, BorderLayout.SOUTH); + this.setLayout(new BorderLayout()); this.add(categoryPane, BorderLayout.NORTH); seriesTypeComboxPane = new SeriesTypeUseComboxPane(parent, new Bar2DPlot()); this.add(seriesTypeComboxPane, BorderLayout.SOUTH); - + addButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -82,11 +82,11 @@ public class CategoryPlotMoreCateTableDataContentPane extends CategoryPlotTableD addNewCombox(); relayoutPane(); } - + checkSeriseUse(categoryCombox.getSelectedItem() != null); } }); - + categoryCombox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { checkSeriseUse(categoryCombox.getSelectedItem() != null); @@ -96,45 +96,45 @@ public class CategoryPlotMoreCateTableDataContentPane extends CategoryPlotTableD } }); } - + protected void checkSeriseUse(boolean hasUse) { super.checkSeriseUse(hasUse); - + addButton.setEnabled(hasUse); } - + private UIComboBox addNewCombox() { - final JPanel buttonPane = new JPanel(); - buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 2)); - - final UIComboBox combox = new UIComboBox(); - combox.setPreferredSize(new Dimension(COMBOX_WIDTH, COMBOX_HEIGHT)); - - int count = categoryCombox.getItemCount(); - for(int i = 0; i < count; i++) { - combox.addItem(categoryCombox.getItemAt(i)); - } - - combox.registerChangeListener(uiobListener); - combox.addItemListener(new ItemListener() { + final JPanel buttonPane = new JPanel(); + buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 2)); + + final UIComboBox combox = new UIComboBox(); + combox.setPreferredSize(new Dimension(COMBOX_WIDTH, COMBOX_HEIGHT)); + + int count = categoryCombox.getItemCount(); + for(int i = 0; i < count; i++) { + combox.addItem(categoryCombox.getItemAt(i)); + } + + combox.registerChangeListener(uiobListener); + combox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { makeToolTipUse(combox); } }); - - combox.setSelectedItem(categoryCombox.getItemAt(0)); - makeToolTipUse(combox); - - buttonPane.add(combox); - UIButton delButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/toolbarbtn/close.png")); - buttonPane.add(delButton); - boxPane.add(buttonPane); - boxList.add(combox); + + combox.setSelectedItem(categoryCombox.getItemAt(0)); + makeToolTipUse(combox); + + buttonPane.add(combox); + UIButton delButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/toolbarbtn/close.png")); + buttonPane.add(delButton); + boxPane.add(buttonPane); + boxList.add(combox); checkComponent(); - - delButton.addActionListener(new ActionListener() { + + delButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { boxPane.remove(buttonPane); @@ -143,11 +143,11 @@ public class CategoryPlotMoreCateTableDataContentPane extends CategoryPlotTableD relayoutPane(); } }); - delButton.registerChangeListener(uiobListener); - - return combox; + delButton.registerChangeListener(uiobListener); + + return combox; } - + private void checkAddButton() { int size = boxList.size(); addButton.setEnabled(size < 2 && categoryCombox.getSelectedItem() != null); @@ -156,11 +156,11 @@ public class CategoryPlotMoreCateTableDataContentPane extends CategoryPlotTableD protected void checkComponent() { checkAddButton(); } - + private void relayoutPane() { this.revalidate(); } - + /** *检查 某些Box是否可用 @@ -171,14 +171,14 @@ public class CategoryPlotMoreCateTableDataContentPane extends CategoryPlotTableD checkComponent(); } - - protected void refreshBoxListWithSelectTableData(List list) { - super.refreshBoxListWithSelectTableData(list); - - for(int i = 0, size = boxList.size(); i < size; i++) { - refreshBoxItems(boxList.get(i), list); - } - } + + protected void refreshBoxListWithSelectTableData(List list) { + super.refreshBoxListWithSelectTableData(list); + + for(int i = 0, size = boxList.size(); i < size; i++) { + refreshBoxItems(boxList.get(i), list); + } + } /** * 给组件登记一个观察者监听事件 @@ -204,9 +204,9 @@ public class CategoryPlotMoreCateTableDataContentPane extends CategoryPlotTableD */ public void populateBean(ChartCollection collection) { super.populateBean(collection); - + boxList.clear(); - + TopDefinitionProvider top = collection.getSelectedChart().getFilterDefinition(); if(top instanceof NormalTableDataDefinition) { NormalTableDataDefinition normal = (NormalTableDataDefinition)top; @@ -216,11 +216,11 @@ public class CategoryPlotMoreCateTableDataContentPane extends CategoryPlotTableD box.setSelectedItem(normal.getMoreCateWithIndex(i)); } } - + checkAddButton(); checkSeriseUse(categoryCombox.getSelectedItem() != null); } - + /** * 保存多分类界面到collection * @param collection From ebe97033437e9c5b7427850cbfb3dc94729888ea Mon Sep 17 00:00:00 2001 From: neil <459208047@qq.com> Date: Tue, 1 Aug 2017 15:31:05 +0800 Subject: [PATCH 26/50] 1 --- designer/src/com/fr/start/Designer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer/src/com/fr/start/Designer.java b/designer/src/com/fr/start/Designer.java index 09b7fa76e..e5502fde2 100644 --- a/designer/src/com/fr/start/Designer.java +++ b/designer/src/com/fr/start/Designer.java @@ -51,7 +51,7 @@ public class Designer extends BaseDesigner { private static final int PREVIEW_DOWN_X_GAP = 92; private static final int GAP = 7; - private static final String OLD_ENV_FOLDER_71 = ".FineReport71"; + private static final String OLD_ENV_FOLDER_71 = ".Fine Report71"; private static final String OLD_ENV_FOLDER_70 = ".FineReport70"; private UserInfoPane userInfoPane; From 5afea688089dc08e761d0bdc01e050a721a7b131 Mon Sep 17 00:00:00 2001 From: neil <459208047@qq.com> Date: Tue, 1 Aug 2017 15:31:15 +0800 Subject: [PATCH 27/50] 1 --- designer/src/com/fr/start/Designer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer/src/com/fr/start/Designer.java b/designer/src/com/fr/start/Designer.java index e5502fde2..09b7fa76e 100644 --- a/designer/src/com/fr/start/Designer.java +++ b/designer/src/com/fr/start/Designer.java @@ -51,7 +51,7 @@ public class Designer extends BaseDesigner { private static final int PREVIEW_DOWN_X_GAP = 92; private static final int GAP = 7; - private static final String OLD_ENV_FOLDER_71 = ".Fine Report71"; + private static final String OLD_ENV_FOLDER_71 = ".FineReport71"; private static final String OLD_ENV_FOLDER_70 = ".FineReport70"; private UserInfoPane userInfoPane; From 60cb686faceb2330b5048f57e510947e8a527981 Mon Sep 17 00:00:00 2001 From: eason-skx Date: Tue, 1 Aug 2017 20:16:30 +0800 Subject: [PATCH 28/50] =?UTF-8?q?=E9=9D=A2=E6=9D=BF=E7=81=B0=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/design/mainframe/chart/gui/ChartTypePane.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypePane.java b/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypePane.java index d5f170ef8..8c5e84dcd 100644 --- a/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypePane.java +++ b/designer_chart/src/com/fr/design/mainframe/chart/gui/ChartTypePane.java @@ -240,7 +240,7 @@ public class ChartTypePane extends AbstractChartAttrPane{ FurtherBasicBeanPane pane = cards.get(i); if (pane.accept(ob)) { - GUICoreUtils.setEnabled(this, ob.isValidPlot()); + GUICoreUtils.setEnabled(chartTypeComBox.getUIComboBox(), ob.isValidPlot()); pane.populateBean(ob); Object item = pane.title4PopupWindow(); From 80d9f3e59a80fe74e11198122c66003efc9a5d37 Mon Sep 17 00:00:00 2001 From: syoki Date: Mon, 7 Aug 2017 14:09:17 +0900 Subject: [PATCH 29/50] =?UTF-8?q?=E3=80=90=E5=9B=BD=E9=99=85=E5=8C=96?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E3=80=91=E6=98=BE=E7=A4=BAbug=EF=BC=88REPORT?= =?UTF-8?q?-3216=EF=BC=89=E7=9B=B8=E5=85=B3key=E7=9A=84=E7=BF=BB=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/design/locale/designer_ja_JP.properties | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/designer_base/src/com/fr/design/locale/designer_ja_JP.properties b/designer_base/src/com/fr/design/locale/designer_ja_JP.properties index c89c2a9d3..ca55e1912 100644 --- a/designer_base/src/com/fr/design/locale/designer_ja_JP.properties +++ b/designer_base/src/com/fr/design/locale/designer_ja_JP.properties @@ -228,7 +228,7 @@ FR-Designer-Collect_Information_free=\u7121\u6599 FR-Designer-Collect_Information_Description=\u8AAC\u660E FR-Designer-Collect_Information_Successfully=\u53CE\u96C6\u6210\u529F FR-Designer_Event_Set=\u30A4\u30D9\u30F3\u30C8\u8A2D\u5B9A -FR-Designer_Blow_set=\u4EE5\u4E0B\u8A2D\u5B9A +FR-Designer_Blow_set=\u6B21\u306E\u8A2D\u5B9A FR-Designer_I_Want_To_Set_Single=\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u500B\u5225\u8A2D\u5B9A FR-Designer_Using_Server_Report_View_Settings=\u30B5\u30FC\u30D0\u8A2D\u5B9A FR-Designer_ErrorHandlerTemplate=\u30A8\u30E9\u30FC\u60C5\u5831\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u5B9A\u7FA9 @@ -507,7 +507,7 @@ FR-Designer_Property_panel=\u5C5E\u6027 FR-Designer_Select_panel=\u9078\u629E FR-Designer_LayoutTable_Column_Width=160 FR-Designer_Set_BG_Of_Current_Row=\u7DE8\u96C6\u884C\u80CC\u666F\u8A2D\u5B9A -FR-Designer_Unload_Check=\u672A\u66F8\u304D\u8FBC\u307F\u6642\u6CE8\u610F +FR-Designer_Unload_Check=\u672A\u30B3\u30DF\u30C3\u30C8\u30D2\u30F3\u30C8 FR-Designer_ReportColumns_Columns_Optional=\u6BB5\u7D44\u307F FR-Designer_Row_Icon_File_Name=row.png FR-Designer_Center_Display=\u4E2D\u592E\u63C3\u3048 @@ -2005,6 +2005,6 @@ FR-Product_Demo=\u88FD\u54C1\u30C7\u30E2 FR-Designer_Data_Filter=\u30C7\u30FC\u30BF\u30D5\u30A3\u30EB\u30BF FR-Designer_Can_not_use_FormatBursh=\u9023\u7D9A\u3057\u306A\u3044\u8907\u6570\u9818\u57DF\u3067\u306F\u66F8\u5F0F\u30B3\u30D4\u30FC\u3092\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093 Default=\u65E2\u5B9A -FR-Designer_Sheet_Label_Page_Display_Position= -FR-Designer_Provide_Choose_All=\u63D0\u4F9B\u3059\u3079\u3066\u9078\u629E -FR-Designer_Decimal_Places=\u5C0F\u6570\u6570\u91CF: \ No newline at end of file +FR-Designer_Sheet_Label_Page_Display_Position=Sheet\u30E9\u30D9\u30EB\u30DA\u30FC\u30B8\u306E\u8868\u793A\u4F4D\u7F6E +FR-Designer_Provide_Choose_All=\u5168\u9078\u629E\u53EF\u80FD +FR-Designer_Decimal_Places=\u5C0F\u6570\u67A0\u6570: \ No newline at end of file From 58c327744504e75056e53400e722d6de02ac8e39 Mon Sep 17 00:00:00 2001 From: hugh Date: Tue, 8 Aug 2017 16:36:22 +0800 Subject: [PATCH 30/50] =?UTF-8?q?SLN-280=20=E6=89=93=E5=8D=B0=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E8=83=8C=E6=99=AF=E5=88=86=E7=A6=BB=EF=BC=8C=E6=BC=8F?= =?UTF-8?q?=E5=88=A0=E4=B8=80=E8=A1=8C=E4=BB=A3=E7=A0=81=EF=BC=8C=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E5=AF=BC=E5=87=BA=E6=8C=89=E9=92=AE=E6=B2=A1=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E5=87=BA=E6=9D=A5=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer/src/com/fr/design/report/ReportBackgroundPane.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/designer/src/com/fr/design/report/ReportBackgroundPane.java b/designer/src/com/fr/design/report/ReportBackgroundPane.java index dcf124792..1abc33c35 100644 --- a/designer/src/com/fr/design/report/ReportBackgroundPane.java +++ b/designer/src/com/fr/design/report/ReportBackgroundPane.java @@ -28,8 +28,6 @@ public class ReportBackgroundPane extends BasicPane { sourth.add(isExportBackgroundCheckBox); sourth.add(isPrintBackgroundCheckBox); this.add(sourth, BorderLayout.SOUTH); - - this.add(isPrintBackgroundCheckBox, BorderLayout.SOUTH); } @Override From 6ee8026f5a6469ed30e5943ae24d4c1a0c01eacd Mon Sep 17 00:00:00 2001 From: juhaoyu <2335173323@qq.com> Date: Thu, 17 Aug 2017 15:58:27 +0800 Subject: [PATCH 31/50] =?UTF-8?q?=E6=8F=92=E4=BB=B6EnvVersion=E6=A3=80?= =?UTF-8?q?=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/design/extra/PluginHelper.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/designer_base/src/com/fr/design/extra/PluginHelper.java b/designer_base/src/com/fr/design/extra/PluginHelper.java index 1230cbfae..1b6fde0d7 100644 --- a/designer_base/src/com/fr/design/extra/PluginHelper.java +++ b/designer_base/src/com/fr/design/extra/PluginHelper.java @@ -6,10 +6,7 @@ import com.fr.design.DesignerEnvManager; import com.fr.design.extra.plugindependence.DownLoadDependenceUI; import com.fr.general.*; import com.fr.general.http.HttpClient; -import com.fr.plugin.Plugin; -import com.fr.plugin.PluginConfigManager; -import com.fr.plugin.PluginLoader; -import com.fr.plugin.PluginManagerHelper; +import com.fr.plugin.*; import com.fr.plugin.dependence.PluginDependence; import com.fr.plugin.dependence.PluginDependenceException; import com.fr.plugin.dependence.PluginDependenceUnit; @@ -268,6 +265,12 @@ public class PluginHelper { FRLogger.getLogger().error(jarExpiredInfo); throw new com.fr.plugin.PluginVerifyException(jarExpiredInfo); } + if (isHigherEnvVersion(plugin.getEnvVersion())) { + String envVersionNotSupport = Inter.getLocText(new String[]{"FR-Designer-Plugin_Jar_Expired", ",", "FR-Designer-Plugin_Install_Failed"}); + FRLogger.getLogger().error(envVersionNotSupport); + throw new com.fr.plugin.PluginVerifyException(envVersionNotSupport); + } + File fileToCheck = getTempPluginFileDirectory(); File oldfile = new File(StableUtils.pathJoin(FRContext.getCurrentEnv().getPath(), ProjectConstants.PLUGINS_NAME, "plugin-" + plugin.getId())); if (!PluginManagerHelper.checkLic(plugin, fileToCheck)) { @@ -278,7 +281,12 @@ public class PluginHelper { } } } - + + private static boolean isHigherEnvVersion(String envVersion) { + //高于8.0 + return PluginUtils.compareVersion(envVersion, "8.0") > 0; + } + /** * 获取插件解压的临时文件夹 * From da225f08dba82f4ea3af0113a4e57a9ef28dec0d Mon Sep 17 00:00:00 2001 From: juhaoyu <2335173323@qq.com> Date: Thu, 17 Aug 2017 16:11:57 +0800 Subject: [PATCH 32/50] =?UTF-8?q?=E6=8F=92=E4=BB=B6EnvVersion=E6=A3=80?= =?UTF-8?q?=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer_base/src/com/fr/design/extra/PluginHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer_base/src/com/fr/design/extra/PluginHelper.java b/designer_base/src/com/fr/design/extra/PluginHelper.java index 1b6fde0d7..798b73294 100644 --- a/designer_base/src/com/fr/design/extra/PluginHelper.java +++ b/designer_base/src/com/fr/design/extra/PluginHelper.java @@ -266,7 +266,7 @@ public class PluginHelper { throw new com.fr.plugin.PluginVerifyException(jarExpiredInfo); } if (isHigherEnvVersion(plugin.getEnvVersion())) { - String envVersionNotSupport = Inter.getLocText(new String[]{"FR-Designer-Plugin_Jar_Expired", ",", "FR-Designer-Plugin_Install_Failed"}); + String envVersionNotSupport = Inter.getLocText(new String[]{"FR-Designer-Plugin_Env_Expired", ",", "FR-Designer-Plugin_Install_Failed"}); FRLogger.getLogger().error(envVersionNotSupport); throw new com.fr.plugin.PluginVerifyException(envVersionNotSupport); } From 3d8723c9fd26d9b2819623368838ad8001f80781 Mon Sep 17 00:00:00 2001 From: juhaoyu <2335173323@qq.com> Date: Thu, 17 Aug 2017 17:22:51 +0800 Subject: [PATCH 33/50] pmd --- .../src/com/fr/design/extra/PluginHelper.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/designer_base/src/com/fr/design/extra/PluginHelper.java b/designer_base/src/com/fr/design/extra/PluginHelper.java index 798b73294..613d887e7 100644 --- a/designer_base/src/com/fr/design/extra/PluginHelper.java +++ b/designer_base/src/com/fr/design/extra/PluginHelper.java @@ -4,9 +4,17 @@ import com.fr.base.Env; import com.fr.base.FRContext; import com.fr.design.DesignerEnvManager; import com.fr.design.extra.plugindependence.DownLoadDependenceUI; -import com.fr.general.*; +import com.fr.general.FRLogger; +import com.fr.general.GeneralUtils; +import com.fr.general.IOUtils; +import com.fr.general.Inter; +import com.fr.general.SiteCenter; import com.fr.general.http.HttpClient; -import com.fr.plugin.*; +import com.fr.plugin.Plugin; +import com.fr.plugin.PluginConfigManager; +import com.fr.plugin.PluginLoader; +import com.fr.plugin.PluginManagerHelper; +import com.fr.plugin.PluginUtils; import com.fr.plugin.dependence.PluginDependence; import com.fr.plugin.dependence.PluginDependenceException; import com.fr.plugin.dependence.PluginDependenceUnit; @@ -112,8 +120,8 @@ public class PluginHelper { */ public static Plugin readPlugin(File chosenFile) throws Exception { // 需要先删除临时目录保证加压出来的文件不会和安装失败的文件混合到一起 - StableUtils.deleteFile(new File(TEMP_PATH)); - + StableUtils.deleteFile(new File(TEMP_PATH)) + IOUtils.unzip(chosenFile, TEMP_PATH); File pluginFileDir = getTempPluginFileDirectory(); if (pluginFileDir == null) { From 03562267356656c74b945178477fcdd8db6b219d Mon Sep 17 00:00:00 2001 From: juhaoyu <2335173323@qq.com> Date: Fri, 18 Aug 2017 09:26:15 +0800 Subject: [PATCH 34/50] fix --- designer_base/src/com/fr/design/extra/PluginHelper.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/designer_base/src/com/fr/design/extra/PluginHelper.java b/designer_base/src/com/fr/design/extra/PluginHelper.java index 613d887e7..cab0a6dbd 100644 --- a/designer_base/src/com/fr/design/extra/PluginHelper.java +++ b/designer_base/src/com/fr/design/extra/PluginHelper.java @@ -20,6 +20,7 @@ import com.fr.plugin.dependence.PluginDependenceException; import com.fr.plugin.dependence.PluginDependenceUnit; import com.fr.stable.ArrayUtils; import com.fr.stable.EncodeConstants; +import com.fr.stable.ProductConstants; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.stable.plugin.PluginConstants; @@ -120,7 +121,7 @@ public class PluginHelper { */ public static Plugin readPlugin(File chosenFile) throws Exception { // 需要先删除临时目录保证加压出来的文件不会和安装失败的文件混合到一起 - StableUtils.deleteFile(new File(TEMP_PATH)) + StableUtils.deleteFile(new File(TEMP_PATH)); IOUtils.unzip(chosenFile, TEMP_PATH); File pluginFileDir = getTempPluginFileDirectory(); @@ -292,7 +293,7 @@ public class PluginHelper { private static boolean isHigherEnvVersion(String envVersion) { //高于8.0 - return PluginUtils.compareVersion(envVersion, "8.0") > 0; + return PluginUtils.compareVersion(envVersion, ProductConstants.MAIN_VERSION) > 0; } /** From 5aa527e37e6ace165e5c9d6070ddbfa77a2d199c Mon Sep 17 00:00:00 2001 From: juhaoyu <2335173323@qq.com> Date: Fri, 18 Aug 2017 11:07:52 +0800 Subject: [PATCH 35/50] =?UTF-8?q?=E6=B7=BB=E5=8A=A0Env=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=8C=BA=E9=97=B4=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/fr/design/extra/PluginHelper.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/designer_base/src/com/fr/design/extra/PluginHelper.java b/designer_base/src/com/fr/design/extra/PluginHelper.java index cab0a6dbd..e79231a3a 100644 --- a/designer_base/src/com/fr/design/extra/PluginHelper.java +++ b/designer_base/src/com/fr/design/extra/PluginHelper.java @@ -15,6 +15,8 @@ import com.fr.plugin.PluginConfigManager; import com.fr.plugin.PluginLoader; import com.fr.plugin.PluginManagerHelper; import com.fr.plugin.PluginUtils; +import com.fr.plugin.basic.Version; +import com.fr.plugin.basic.VersionIntervalFactory; import com.fr.plugin.dependence.PluginDependence; import com.fr.plugin.dependence.PluginDependenceException; import com.fr.plugin.dependence.PluginDependenceUnit; @@ -274,7 +276,7 @@ public class PluginHelper { FRLogger.getLogger().error(jarExpiredInfo); throw new com.fr.plugin.PluginVerifyException(jarExpiredInfo); } - if (isHigherEnvVersion(plugin.getEnvVersion())) { + if (!isSupportCurrentEnv(plugin.getEnvVersion())) { String envVersionNotSupport = Inter.getLocText(new String[]{"FR-Designer-Plugin_Env_Expired", ",", "FR-Designer-Plugin_Install_Failed"}); FRLogger.getLogger().error(envVersionNotSupport); throw new com.fr.plugin.PluginVerifyException(envVersionNotSupport); @@ -291,9 +293,9 @@ public class PluginHelper { } } - private static boolean isHigherEnvVersion(String envVersion) { - //高于8.0 - return PluginUtils.compareVersion(envVersion, ProductConstants.MAIN_VERSION) > 0; + private static boolean isSupportCurrentEnv(String envVersion) { + //包含8.0 + return !VersionIntervalFactory.create(envVersion).contain(Version.currentEnvVersion()); } /** From c465dc4b106ad734b52c73b738d525c377e8ae70 Mon Sep 17 00:00:00 2001 From: juhaoyu <2335173323@qq.com> Date: Fri, 18 Aug 2017 11:10:24 +0800 Subject: [PATCH 36/50] pmd --- designer_base/src/com/fr/design/extra/PluginHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer_base/src/com/fr/design/extra/PluginHelper.java b/designer_base/src/com/fr/design/extra/PluginHelper.java index e79231a3a..2524412c0 100644 --- a/designer_base/src/com/fr/design/extra/PluginHelper.java +++ b/designer_base/src/com/fr/design/extra/PluginHelper.java @@ -295,7 +295,7 @@ public class PluginHelper { private static boolean isSupportCurrentEnv(String envVersion) { //包含8.0 - return !VersionIntervalFactory.create(envVersion).contain(Version.currentEnvVersion()); + return VersionIntervalFactory.create(envVersion).contain(Version.currentEnvVersion()); } /** From 06fcc30d00e2e1e6bc88b1b36e8a3f2e4a46692a Mon Sep 17 00:00:00 2001 From: juhaoyu <2335173323@qq.com> Date: Fri, 18 Aug 2017 11:11:51 +0800 Subject: [PATCH 37/50] pmd --- designer_base/src/com/fr/design/extra/PluginHelper.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/designer_base/src/com/fr/design/extra/PluginHelper.java b/designer_base/src/com/fr/design/extra/PluginHelper.java index 2524412c0..65cd74a2c 100644 --- a/designer_base/src/com/fr/design/extra/PluginHelper.java +++ b/designer_base/src/com/fr/design/extra/PluginHelper.java @@ -14,15 +14,13 @@ import com.fr.plugin.Plugin; import com.fr.plugin.PluginConfigManager; import com.fr.plugin.PluginLoader; import com.fr.plugin.PluginManagerHelper; -import com.fr.plugin.PluginUtils; -import com.fr.plugin.basic.Version; -import com.fr.plugin.basic.VersionIntervalFactory; +import com.fr.plugin.basic.version.Version; +import com.fr.plugin.basic.version.VersionIntervalFactory; import com.fr.plugin.dependence.PluginDependence; import com.fr.plugin.dependence.PluginDependenceException; import com.fr.plugin.dependence.PluginDependenceUnit; import com.fr.stable.ArrayUtils; import com.fr.stable.EncodeConstants; -import com.fr.stable.ProductConstants; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; import com.fr.stable.plugin.PluginConstants; From 78f790501594a656cfc3a535241c1448ffcd3b1f Mon Sep 17 00:00:00 2001 From: juhaoyu <2335173323@qq.com> Date: Fri, 18 Aug 2017 14:11:16 +0800 Subject: [PATCH 38/50] =?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=20=E7=A7=BB=E6=A4=8D9.0=E7=9A=84?= =?UTF-8?q?=E5=8A=A0=E5=AF=86=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer_base/src/com/fr/start/BaseDesigner.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/designer_base/src/com/fr/start/BaseDesigner.java b/designer_base/src/com/fr/start/BaseDesigner.java index 4c98ea199..49c49d9b5 100644 --- a/designer_base/src/com/fr/start/BaseDesigner.java +++ b/designer_base/src/com/fr/start/BaseDesigner.java @@ -24,6 +24,7 @@ import com.fr.file.FILEFactory; import com.fr.file.FileFILE; import com.fr.general.*; import com.fr.plugin.PluginCollector; +import com.fr.plugin.manager.PluginManager; import com.fr.stable.*; import javax.swing.*; @@ -83,6 +84,8 @@ public abstract class BaseDesigner extends ToolBarMenuDock { DesignUtils.initLookAndFeel(); DesignUtils.creatListeningServer(getStartPort(), startFileSuffix()); + //初始化插件引擎 + PluginManager.init(); // 初始化Log Handler DesignerEnvManager.loadLogSetting(); DesignerFrame df = createDesignerFrame(); From ba2a78b8aefa1929877c9f3621c00dcaf74a7f33 Mon Sep 17 00:00:00 2001 From: juhaoyu <2335173323@qq.com> Date: Fri, 18 Aug 2017 14:39:39 +0800 Subject: [PATCH 39/50] pmd --- designer_base/src/com/fr/design/extra/PluginHelper.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/designer_base/src/com/fr/design/extra/PluginHelper.java b/designer_base/src/com/fr/design/extra/PluginHelper.java index 65cd74a2c..c0aeff8e7 100644 --- a/designer_base/src/com/fr/design/extra/PluginHelper.java +++ b/designer_base/src/com/fr/design/extra/PluginHelper.java @@ -20,6 +20,7 @@ import com.fr.plugin.dependence.PluginDependence; import com.fr.plugin.dependence.PluginDependenceException; import com.fr.plugin.dependence.PluginDependenceUnit; import com.fr.stable.ArrayUtils; +import com.fr.stable.AssistUtils; import com.fr.stable.EncodeConstants; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; @@ -133,7 +134,7 @@ public class PluginHelper { File[] pluginFiles = pluginFileDir.listFiles(); if (ArrayUtils.isNotEmpty(pluginFiles)) { for (File f : pluginFiles) { - if (f.getName().equals("plugin.xml")) { + if (AssistUtils.equals(f.getName(), "plugin.xml")) { plugin = new Plugin(); InputStream inputStream = plugin.readEncryptXml(new FileInputStream(f)); XMLTools.readInputStreamXML(plugin, inputStream); @@ -323,7 +324,7 @@ public class PluginHelper { File[] files = dir.listFiles(); if (ArrayUtils.isNotEmpty(files)) { for (File f : files) { - if ("plugin.xml".equals(f.getName())) { + if (AssistUtils.equals("plugin.xml",f.getName())) { return true; } } From ba1e541f1458248b2e8365c0fbe9bca9048888d3 Mon Sep 17 00:00:00 2001 From: juhaoyu <2335173323@qq.com> Date: Fri, 18 Aug 2017 14:40:19 +0800 Subject: [PATCH 40/50] pmd --- designer_base/src/com/fr/design/extra/PluginHelper.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/designer_base/src/com/fr/design/extra/PluginHelper.java b/designer_base/src/com/fr/design/extra/PluginHelper.java index c0aeff8e7..dcf5a6c89 100644 --- a/designer_base/src/com/fr/design/extra/PluginHelper.java +++ b/designer_base/src/com/fr/design/extra/PluginHelper.java @@ -283,12 +283,11 @@ public class PluginHelper { File fileToCheck = getTempPluginFileDirectory(); File oldfile = new File(StableUtils.pathJoin(FRContext.getCurrentEnv().getPath(), ProjectConstants.PLUGINS_NAME, "plugin-" + plugin.getId())); - if (!PluginManagerHelper.checkLic(plugin, fileToCheck)) { - if (!PluginManagerHelper.checkLic(plugin, oldfile)) {//安装时,在安装目录下和压缩包里都没有才弹框 + if (!PluginManagerHelper.checkLic(plugin, fileToCheck) && !PluginManagerHelper.checkLic(plugin, oldfile)) { + //安装时,在安装目录下和压缩包里都没有才弹框 String checkLicFail = Inter.getLocText("FR-Designer-PluginLicense_Check_Failed"); FRLogger.getLogger().error(checkLicFail); throw new com.fr.plugin.PluginVerifyException(checkLicFail); - } } } From 2a5a2e10054f78574975f94e22794e9a32a56797 Mon Sep 17 00:00:00 2001 From: juhaoyu <2335173323@qq.com> Date: Fri, 18 Aug 2017 14:40:43 +0800 Subject: [PATCH 41/50] pmd --- designer_base/src/com/fr/design/extra/PluginHelper.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/designer_base/src/com/fr/design/extra/PluginHelper.java b/designer_base/src/com/fr/design/extra/PluginHelper.java index dcf5a6c89..0d7bc4eac 100644 --- a/designer_base/src/com/fr/design/extra/PluginHelper.java +++ b/designer_base/src/com/fr/design/extra/PluginHelper.java @@ -307,7 +307,7 @@ public class PluginHelper { File[] files = file.listFiles(); if (ArrayUtils.isNotEmpty(files)) { for (File f : files) { - if (foundConfigFile(f)) { + if (hasFoundConfigFile(f)) { return f; } } @@ -316,7 +316,7 @@ public class PluginHelper { return null; } - private static boolean foundConfigFile(File dir) { + private static boolean hasFoundConfigFile(File dir) { if (!dir.isDirectory()) { return false; } From c9e30586ecf68c7ae092db9f19b385b0705ae78b Mon Sep 17 00:00:00 2001 From: juhaoyu <2335173323@qq.com> Date: Fri, 18 Aug 2017 14:40:58 +0800 Subject: [PATCH 42/50] pmd --- designer_base/src/com/fr/design/extra/PluginHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer_base/src/com/fr/design/extra/PluginHelper.java b/designer_base/src/com/fr/design/extra/PluginHelper.java index 0d7bc4eac..c2bb480ec 100644 --- a/designer_base/src/com/fr/design/extra/PluginHelper.java +++ b/designer_base/src/com/fr/design/extra/PluginHelper.java @@ -86,7 +86,7 @@ public class PluginHelper { } } - private static boolean invalidUser(String id, String username, String password) { + private static boolean isInvalidUser(String id, String username, String password) { if (StringUtils.isEmpty(id)) { return false; } else if (StringUtils.isEmpty(username) || StringUtils.isEmpty(password)){ From 016f5c2af133b1a2a63cda5e55eaebf003432b91 Mon Sep 17 00:00:00 2001 From: juhaoyu <2335173323@qq.com> Date: Fri, 18 Aug 2017 17:13:19 +0800 Subject: [PATCH 43/50] bugfix --- designer_base/src/com/fr/start/BaseDesigner.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer_base/src/com/fr/start/BaseDesigner.java b/designer_base/src/com/fr/start/BaseDesigner.java index 49c49d9b5..5d76b6a19 100644 --- a/designer_base/src/com/fr/start/BaseDesigner.java +++ b/designer_base/src/com/fr/start/BaseDesigner.java @@ -24,7 +24,7 @@ import com.fr.file.FILEFactory; import com.fr.file.FileFILE; import com.fr.general.*; import com.fr.plugin.PluginCollector; -import com.fr.plugin.manager.PluginManager; +import com.fr.plugin.manage.PluginManager; import com.fr.stable.*; import javax.swing.*; From 01fcdf0740a4df44667977dd1dedecdb7a391a80 Mon Sep 17 00:00:00 2001 From: rinoux Date: Thu, 24 Aug 2017 11:31:46 +0800 Subject: [PATCH 44/50] =?UTF-8?q?PFC-982=20=E4=BF=AE=E5=A4=8D=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=E6=A0=8F=E6=9D=83=E9=99=90=E9=A2=97=E7=B2=92=E5=BA=A6?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E6=97=B6=E5=8D=A1=E6=AD=BB=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/AuthorityEditToolBarPane.java | 31 ++++++++++--------- .../mainframe/AuthorityToolBarPane.java | 31 ++++++++++--------- 2 files changed, 32 insertions(+), 30 deletions(-) diff --git a/designer/src/com/fr/design/mainframe/AuthorityEditToolBarPane.java b/designer/src/com/fr/design/mainframe/AuthorityEditToolBarPane.java index a760e0043..d26b2d6eb 100644 --- a/designer/src/com/fr/design/mainframe/AuthorityEditToolBarPane.java +++ b/designer/src/com/fr/design/mainframe/AuthorityEditToolBarPane.java @@ -1,5 +1,6 @@ package com.fr.design.mainframe; +import com.fr.base.FRContext; import com.fr.design.constants.LayoutConstants; import com.fr.design.constants.UIConstants; import com.fr.design.file.HistoryTemplateListPane; @@ -20,6 +21,7 @@ import javax.swing.tree.TreePath; import java.awt.*; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; +import java.util.ArrayList; import java.util.List; /** @@ -96,23 +98,22 @@ public class AuthorityEditToolBarPane extends AuthorityPropertyPane { null || selectedPathArray == null) { return; } - for (int t = 0; t < selectedPathArray.length; t++) { - for (int i = 0; i < buttonlists.size(); i++) { - if (buttonlists.get(i).isSelected()) { - buttonlists.get(i).changeAuthorityState(selectedPathArray[t], buttonVisible.isSelected()); - authorityToolBarPane.repaint(); - } + ToolBarButton selectedButton = null; + //是否可见的checkbox + UICheckBox checkbox = (UICheckBox) e.getSource(); + for (int i = 0; i < buttonlists.size(); i++) { + if (buttonlists.get(i).isSelected()) { + selectedButton = buttonlists.get(i); } - HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().fireTargetModified(); - RolesAlreadyEditedPane.getInstance().refreshDockingView(); - UICheckBox checkbox = (UICheckBox) e.getSource(); - List btns = AuthorityEditPane.this.buttonlists; - for (int j = 0; j < btns.size(); j++) { - if (btns.get(j).isSelected()) { - //由引擎实现保存进模板报表 - authorityToolBarPane.setAuthorityWebAttr(btns.get(j).getWidget(), checkbox.isSelected(), selectedPathArray[t]); - } + } + if (selectedButton != null) { + for (int t = 0; t < selectedPathArray.length; t++) { + selectedButton.changeAuthorityState(selectedPathArray[t], buttonVisible.isSelected()); + authorityToolBarPane.repaint(); + authorityToolBarPane.setAuthorityWebAttr(selectedButton.getWidget(), checkbox.isSelected(), selectedPathArray[t]); } + HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().fireTargetModified();//模版更新 + RolesAlreadyEditedPane.getInstance().refreshDockingView();//已配置角色视图刷新 } } }; diff --git a/designer/src/com/fr/design/mainframe/AuthorityToolBarPane.java b/designer/src/com/fr/design/mainframe/AuthorityToolBarPane.java index da856173a..53c8893ec 100644 --- a/designer/src/com/fr/design/mainframe/AuthorityToolBarPane.java +++ b/designer/src/com/fr/design/mainframe/AuthorityToolBarPane.java @@ -219,23 +219,24 @@ public class AuthorityToolBarPane extends BasicBeanPane Date: Thu, 24 Aug 2017 14:51:24 +0800 Subject: [PATCH 45/50] sonarCube --- .../mainframe/AuthorityEditToolBarPane.java | 28 +++++++++------- .../mainframe/AuthorityToolBarPane.java | 33 ++++++++++--------- 2 files changed, 33 insertions(+), 28 deletions(-) diff --git a/designer/src/com/fr/design/mainframe/AuthorityEditToolBarPane.java b/designer/src/com/fr/design/mainframe/AuthorityEditToolBarPane.java index d26b2d6eb..0b016c57e 100644 --- a/designer/src/com/fr/design/mainframe/AuthorityEditToolBarPane.java +++ b/designer/src/com/fr/design/mainframe/AuthorityEditToolBarPane.java @@ -15,6 +15,7 @@ import com.fr.design.roleAuthority.RolesAlreadyEditedPane; import com.fr.design.webattr.ToolBarButton; import com.fr.general.ComparatorUtils; import com.fr.general.Inter; +import com.fr.stable.StringUtils; import javax.swing.*; import javax.swing.tree.TreePath; @@ -37,8 +38,12 @@ public class AuthorityEditToolBarPane extends AuthorityPropertyPane { private AuthorityToolBarPane authorityToolBarPane; private String[] selectedPathArray; - public AuthorityEditToolBarPane(List buttonlists) { + public AuthorityEditToolBarPane(List buttonList) { super(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); + this.init(buttonList); + } + + private void init(List buttonList) { this.setLayout(new BorderLayout()); this.setBorder(null); UILabel authorityTitle = new UILabel(Inter.getLocText(new String[]{"FR-Designer_Permissions", @@ -54,7 +59,7 @@ public class AuthorityEditToolBarPane extends AuthorityPropertyPane { northPane.add(authorityTitle, BorderLayout.CENTER); northPane.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, UIConstants.LINE_COLOR)); this.add(northPane, BorderLayout.NORTH); - authorityEditPane = new AuthorityEditPane(buttonlists); + authorityEditPane = new AuthorityEditPane(buttonList); this.add(authorityEditPane, BorderLayout.CENTER); } @@ -94,8 +99,7 @@ public class AuthorityEditToolBarPane extends AuthorityPropertyPane { public void itemStateChanged(ItemEvent e) { String selectedRole = ReportAndFSManagePane.getInstance().getRoleTree().getSelectedRoleName(); initSelectedPathArray(); - if (ComparatorUtils.equals(selectedRole, Inter.getLocText("FR-Designer_Role")) || selectedRole == - null || selectedPathArray == null) { + if (ComparatorUtils.equals(selectedRole, Inter.getLocText("FR-Designer_Role")) || selectedRole == null || selectedPathArray == null) { return; } ToolBarButton selectedButton = null; @@ -210,29 +214,29 @@ public class AuthorityEditToolBarPane extends AuthorityPropertyPane { public void populateType() { - if (name.getText() == "") { - type.setText(""); + if (StringUtils.EMPTY.equals(name.getText())) { + type.setText(StringUtils.EMPTY); } else { type.setText(Inter.getLocText(new String[]{"ReportServerP-Toolbar", "FR-Designer_Form_Button"})); } } public void populateName() { - String names = ""; + StringBuilder names = new StringBuilder(); for (int i = 0; i < buttonlists.size(); i++) { if (buttonlists.get(i).isSelected()) { - names += "," + buttonlists.get(i).getNameOption().optionName(); + names.append(",").append(buttonlists.get(i).getNameOption().optionName()); } } - if (names != "") { - names = names.substring(1); + if (names.length() > 0) { + names.deleteCharAt(0); } - name.setText(names); + name.setText(names.toString()); } public void populateCheckPane() { checkPane.removeAll(); - if (name.getText() == "") { + if (StringUtils.EMPTY.equals(name.getText())) { return; } double f = TableLayout.FILL; diff --git a/designer/src/com/fr/design/mainframe/AuthorityToolBarPane.java b/designer/src/com/fr/design/mainframe/AuthorityToolBarPane.java index 53c8893ec..44125ce1b 100644 --- a/designer/src/com/fr/design/mainframe/AuthorityToolBarPane.java +++ b/designer/src/com/fr/design/mainframe/AuthorityToolBarPane.java @@ -215,26 +215,27 @@ public class AuthorityToolBarPane extends BasicBeanPane Date: Thu, 24 Aug 2017 14:55:24 +0800 Subject: [PATCH 46/50] sonarCube2 --- .../fr/design/mainframe/AuthorityToolBarPane.java | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/designer/src/com/fr/design/mainframe/AuthorityToolBarPane.java b/designer/src/com/fr/design/mainframe/AuthorityToolBarPane.java index 44125ce1b..682ddc308 100644 --- a/designer/src/com/fr/design/mainframe/AuthorityToolBarPane.java +++ b/designer/src/com/fr/design/mainframe/AuthorityToolBarPane.java @@ -215,7 +215,7 @@ public class AuthorityToolBarPane extends BasicBeanPane extends BasicBeanPane Date: Thu, 24 Aug 2017 15:06:46 +0800 Subject: [PATCH 47/50] Sonar --- .../fr/design/mainframe/AuthorityToolBarPane.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/designer/src/com/fr/design/mainframe/AuthorityToolBarPane.java b/designer/src/com/fr/design/mainframe/AuthorityToolBarPane.java index 682ddc308..7cd193086 100644 --- a/designer/src/com/fr/design/mainframe/AuthorityToolBarPane.java +++ b/designer/src/com/fr/design/mainframe/AuthorityToolBarPane.java @@ -242,14 +242,11 @@ public class AuthorityToolBarPane extends BasicBeanPane Date: Fri, 25 Aug 2017 16:07:56 +0800 Subject: [PATCH 48/50] 1 --- .../com/fr/design/locale/designer_ja_JP.properties | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/designer_base/src/com/fr/design/locale/designer_ja_JP.properties b/designer_base/src/com/fr/design/locale/designer_ja_JP.properties index ca55e1912..11f0fb0d9 100644 --- a/designer_base/src/com/fr/design/locale/designer_ja_JP.properties +++ b/designer_base/src/com/fr/design/locale/designer_ja_JP.properties @@ -228,7 +228,7 @@ FR-Designer-Collect_Information_free=\u7121\u6599 FR-Designer-Collect_Information_Description=\u8AAC\u660E FR-Designer-Collect_Information_Successfully=\u53CE\u96C6\u6210\u529F FR-Designer_Event_Set=\u30A4\u30D9\u30F3\u30C8\u8A2D\u5B9A -FR-Designer_Blow_set=\u6B21\u306E\u8A2D\u5B9A +FR-Designer_Blow_set=\u4EE5\u4E0B\u8A2D\u5B9A FR-Designer_I_Want_To_Set_Single=\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u500B\u5225\u8A2D\u5B9A FR-Designer_Using_Server_Report_View_Settings=\u30B5\u30FC\u30D0\u8A2D\u5B9A FR-Designer_ErrorHandlerTemplate=\u30A8\u30E9\u30FC\u60C5\u5831\u30C6\u30F3\u30D7\u30EC\u30FC\u30C8\u5B9A\u7FA9 @@ -507,7 +507,7 @@ FR-Designer_Property_panel=\u5C5E\u6027 FR-Designer_Select_panel=\u9078\u629E FR-Designer_LayoutTable_Column_Width=160 FR-Designer_Set_BG_Of_Current_Row=\u7DE8\u96C6\u884C\u80CC\u666F\u8A2D\u5B9A -FR-Designer_Unload_Check=\u672A\u30B3\u30DF\u30C3\u30C8\u30D2\u30F3\u30C8 +FR-Designer_Unload_Check=\u672A\u66F8\u304D\u8FBC\u307F\u6642\u6CE8\u610F FR-Designer_ReportColumns_Columns_Optional=\u6BB5\u7D44\u307F FR-Designer_Row_Icon_File_Name=row.png FR-Designer_Center_Display=\u4E2D\u592E\u63C3\u3048 @@ -2005,6 +2005,7 @@ FR-Product_Demo=\u88FD\u54C1\u30C7\u30E2 FR-Designer_Data_Filter=\u30C7\u30FC\u30BF\u30D5\u30A3\u30EB\u30BF FR-Designer_Can_not_use_FormatBursh=\u9023\u7D9A\u3057\u306A\u3044\u8907\u6570\u9818\u57DF\u3067\u306F\u66F8\u5F0F\u30B3\u30D4\u30FC\u3092\u4F7F\u7528\u3067\u304D\u307E\u305B\u3093 Default=\u65E2\u5B9A -FR-Designer_Sheet_Label_Page_Display_Position=Sheet\u30E9\u30D9\u30EB\u30DA\u30FC\u30B8\u306E\u8868\u793A\u4F4D\u7F6E -FR-Designer_Provide_Choose_All=\u5168\u9078\u629E\u53EF\u80FD -FR-Designer_Decimal_Places=\u5C0F\u6570\u67A0\u6570: \ No newline at end of file +FR-Designer_Sheet_Label_Page_Display_Position= +FR-Designer_Provide_Choose_All=\u63D0\u4F9B\u3059\u3079\u3066\u9078\u629E +FR-Designer_Decimal_Places=\u5C0F\u6570\u6570\u91CF: +FR-Base-Load_Resource_File=\u8A2D\u5B9A\u30D5\u30A1\u30A4\u30EB\u30ED\u30FC\u30C9 \ No newline at end of file From 9570cd5645eb0216dd0ad927dc0c2820a16b9fd1 Mon Sep 17 00:00:00 2001 From: neil <459208047@qq.com> Date: Fri, 25 Aug 2017 16:11:22 +0800 Subject: [PATCH 49/50] 1 --- designer_base/src/com/fr/design/locale/designer.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer_base/src/com/fr/design/locale/designer.properties b/designer_base/src/com/fr/design/locale/designer.properties index 643fbf16a..5bac16ca9 100644 --- a/designer_base/src/com/fr/design/locale/designer.properties +++ b/designer_base/src/com/fr/design/locale/designer.properties @@ -1,4 +1,4 @@ -FR-Designer-BBSLogin_Account= + FR-Designer-BBSLogin_Account= FR-Designer-BBSLogin_Connection-Failure= FR-Designer-BBSLogin_Connection-Failure-Tip= FR-Designer-BBSLogin_Forgot-Password= From 96269140176b56a0401819f547254c4260f96356 Mon Sep 17 00:00:00 2001 From: neil <459208047@qq.com> Date: Fri, 25 Aug 2017 16:12:23 +0800 Subject: [PATCH 50/50] 1 --- designer_base/src/com/fr/design/locale/designer.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer_base/src/com/fr/design/locale/designer.properties b/designer_base/src/com/fr/design/locale/designer.properties index 5bac16ca9..643fbf16a 100644 --- a/designer_base/src/com/fr/design/locale/designer.properties +++ b/designer_base/src/com/fr/design/locale/designer.properties @@ -1,4 +1,4 @@ - FR-Designer-BBSLogin_Account= +FR-Designer-BBSLogin_Account= FR-Designer-BBSLogin_Connection-Failure= FR-Designer-BBSLogin_Connection-Failure-Tip= FR-Designer-BBSLogin_Forgot-Password=