From bc985fa66966bed0d8f4883194cb6b722628af59 Mon Sep 17 00:00:00 2001 From: mengao <283296419@qq.com> Date: Wed, 13 Sep 2017 10:12:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E6=8E=89design=E4=B8=AD=E9=83=A8?= =?UTF-8?q?=E5=88=86todo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...egoryPlotMoreCateTableDataContentPane.java | 409 +++++++++--------- ...VanChartMoreCateReportDataContentPane.java | 27 +- .../VanChartMoreCateTableDataContentPane.java | 27 +- 3 files changed, 238 insertions(+), 225 deletions(-) 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 b656a549b6..9dd0b71b96 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; @@ -26,212 +27,230 @@ import java.util.List; /** * 多分类轴 的数据集定义界面. + * * @author kunsnat E-mail:kunsnat@gmail.com * @version 创建时间:2013-9-3 上午10:00:28 */ -public class CategoryPlotMoreCateTableDataContentPane extends CategoryPlotTableDataContentPane implements UIObserver{ - private static final long serialVersionUID = -3305681053750642843L; - private static final int COMBOX_GAP = 8; - private static final int COMBOX_WIDTH = 95; - private static final int COMBOX_HEIGHT = 20; - - private JPanel boxPane; - - private ArrayList boxList = new ArrayList(); - private UIButton addButton; - - private UIObserverListener uiobListener = null; - - public CategoryPlotMoreCateTableDataContentPane() { - // do nothing - } - - public CategoryPlotMoreCateTableDataContentPane(ChartDataPane parent) { - categoryCombox = new UIComboBox(); - categoryCombox.setPreferredSize(new Dimension(COMBOX_WIDTH,COMBOX_HEIGHT)); - - 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")) ; +public class CategoryPlotMoreCateTableDataContentPane extends CategoryPlotTableDataContentPane implements UIObserver { + private static final long serialVersionUID = -3305681053750642843L; + private static final int COMBOX_GAP = 8; + private static final int COMBOX_WIDTH = 95; + 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() { + return boxList; + } + + public CategoryPlotMoreCateTableDataContentPane() { + // do nothing + } + + public CategoryPlotMoreCateTableDataContentPane(ChartDataPane parent) { + categoryCombox = new UIComboBox(); + categoryCombox.setPreferredSize(new Dimension(COMBOX_WIDTH,COMBOX_HEIGHT)); + + 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")); categoryLabel.setPreferredSize(new Dimension(85,COMBOX_HEIGHT)); - + addButton = new UIButton(BaseUtils.readIcon("/com/fr/design/images/buttonicon/add.png")); addButton.setPreferredSize(new Dimension(20, COMBOX_HEIGHT)); - - categoryPane.add(GUICoreUtils.createBorderLayoutPane(new Component[]{categoryCombox, addButton,null,categoryLabel,null})); - categoryPane.setBorder(BorderFactory.createEmptyBorder(0,24,10,15)); + categoryPane.add(GUICoreUtils.createBorderLayoutPane(new Component[]{categoryCombox, addButton, null, categoryLabel, null})); - boxPane = new JPanel(); + categoryPane.setBorder(BorderFactory.createEmptyBorder(0,24,10,15)); + + 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); - this.add(getJSeparator()); - seriesTypeComboxPane = new SeriesTypeUseComboxPane(parent, new Bar2DPlot()); - this.add(seriesTypeComboxPane, BorderLayout.SOUTH); - - addButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - if(boxList.size() < 2) { - addNewCombox(); - relayoutPane(); - } - - checkSeriseUse(categoryCombox.getSelectedItem() != null); - } - }); - - categoryCombox.addItemListener(new ItemListener() { - public void itemStateChanged(ItemEvent e) { - checkSeriseUse(categoryCombox.getSelectedItem() != null); - makeToolTipUse(categoryCombox); - - checkAddButton(); - } - }); - } - - 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() { - @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); - - checkAddButton(); - - delButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - boxPane.remove(buttonPane); - boxList.remove(combox); - checkAddButton(); - relayoutPane(); - } - }); - delButton.registerChangeListener(uiobListener); - - return combox; - } - - private void checkAddButton() { - int size = boxList.size(); - addButton.setEnabled(size < 2 && categoryCombox.getSelectedItem() != null); - } - - private void relayoutPane() { - this.revalidate(); - } - - - /** - *检查 某些Box是否可用 - * @param hasUse 是否使用. - */ - public void checkBoxUse(boolean hasUse) { - super.checkBoxUse(hasUse); - - checkAddButton(); - } - + + this.setLayout(new BorderLayout()); + this.add(categoryPane, BorderLayout.NORTH); + this.add(getJSeparator()); + seriesTypeComboxPane = new SeriesTypeUseComboxPane(parent, new Bar2DPlot()); + this.add(seriesTypeComboxPane, BorderLayout.SOUTH); + + addButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if (boxList.size() < 2) { + addNewCombox(); + relayoutPane(); + } + + checkSeriseUse(categoryCombox.getSelectedItem() != null); + } + }); + + categoryCombox.addItemListener(new ItemListener() { + public void itemStateChanged(ItemEvent e) { + checkSeriseUse(categoryCombox.getSelectedItem() != null); + makeToolTipUse(categoryCombox); + + checkComponent(); + } + }); + } + + 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() { + @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); + + checkComponent(); + + delButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + boxPane.remove(buttonPane); + boxList.remove(combox); + checkComponent(); + relayoutPane(); + } + }); + delButton.registerChangeListener(uiobListener); + + return combox; + } + + private void checkAddButton() { + int size = boxList.size(); + addButton.setEnabled(size < 2 && categoryCombox.getSelectedItem() != null); + } + + protected void checkComponent() { + checkAddButton(); + } + + private void relayoutPane() { + this.revalidate(); + } + + + /** + * 检查 某些Box是否可用 + * + * @param hasUse 是否使用. + */ + public void checkBoxUse(boolean hasUse) { + super.checkBoxUse(hasUse); + + checkComponent(); + } + protected void refreshBoxListWithSelectTableData(List list) { - super.refreshBoxListWithSelectTableData(list); - - for(int i = 0, size = boxList.size(); i < size; i++) { - refreshBoxItems(boxList.get(i), list); - } + super.refreshBoxListWithSelectTableData(list); + + for (int i = 0, size = boxList.size(); i < size; i++) { + refreshBoxItems(boxList.get(i), list); + } + } + + /** + * 给组件登记一个观察者监听事件 + * + * @param listener 观察者监听事件 + */ + public void registerChangeListener(UIObserverListener listener) { + uiobListener = listener; + } + + /** + * 组件是否需要响应添加的观察者事件 + * + * @return 如果需要响应观察者事件则返回true,否则返回false + */ + public boolean shouldResponseChangeListener() { + return true; + } + + /** + * 更新 多分类相关界面 + * + * @param collection + */ + public void populateBean(ChartCollection collection) { + super.populateBean(collection); + + boxList.clear(); + + TopDefinitionProvider top = collection.getSelectedChart().getFilterDefinition(); + if (top instanceof NormalTableDataDefinition) { + NormalTableDataDefinition normal = (NormalTableDataDefinition) top; + int size = normal.getMoreCateSize(); + for (int i = 0; i < size; i++) { + UIComboBox box = addNewCombox(); + box.setSelectedItem(normal.getMoreCateWithIndex(i)); + } + } + + checkAddButton(); + checkSeriseUse(categoryCombox.getSelectedItem() != null); + } + + /** + * 保存多分类界面到collection + * + * @param collection + */ + public void updateBean(ChartCollection collection) { + super.updateBean(collection); + + TopDefinitionProvider top = collection.getSelectedChart().getFilterDefinition(); + Plot plot = collection.getSelectedChart().getPlot(); + if (top instanceof NormalTableDataDefinition) { + NormalTableDataDefinition normal = (NormalTableDataDefinition) top; + normal.clearMoreCate(); + 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()); + } + } } - /** - * 给组件登记一个观察者监听事件 - * - * @param listener 观察者监听事件 - */ - public void registerChangeListener(UIObserverListener listener) { - uiobListener = listener; - } - - /** - * 组件是否需要响应添加的观察者事件 - * - * @return 如果需要响应观察者事件则返回true,否则返回false - */ - public boolean shouldResponseChangeListener() { - return true; - } - - /** - * 更新 多分类相关界面 - * @param collection - */ - public void populateBean(ChartCollection collection) { - super.populateBean(collection); - - boxList.clear(); - - TopDefinitionProvider top = collection.getSelectedChart().getFilterDefinition(); - if(top instanceof NormalTableDataDefinition) { - NormalTableDataDefinition normal = (NormalTableDataDefinition)top; - int size = normal.getMoreCateSize(); - for(int i = 0; i < size; i++) { - UIComboBox box = addNewCombox(); - box.setSelectedItem(normal.getMoreCateWithIndex(i)); - } - } - - checkAddButton(); - checkSeriseUse(categoryCombox.getSelectedItem() != null); - } - - /** - * 保存多分类界面到collection - * @param collection - */ - public void updateBean(ChartCollection collection) { - super.updateBean(collection); - - TopDefinitionProvider top = collection.getSelectedChart().getFilterDefinition(); - 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()); - } - } - } - } } \ No newline at end of file diff --git a/designer_chart/src/com/fr/plugin/chart/designer/data/VanChartMoreCateReportDataContentPane.java b/designer_chart/src/com/fr/plugin/chart/designer/data/VanChartMoreCateReportDataContentPane.java index 9452586a21..072127ae83 100644 --- a/designer_chart/src/com/fr/plugin/chart/designer/data/VanChartMoreCateReportDataContentPane.java +++ b/designer_chart/src/com/fr/plugin/chart/designer/data/VanChartMoreCateReportDataContentPane.java @@ -27,27 +27,24 @@ public class VanChartMoreCateReportDataContentPane extends CategoryPlotMoreCateR } protected void updateMoreCate(NormalReportDataDefinition reportDefinition, Plot plot) { - //todo@shine9.0 -// super.updateMoreCate(reportDefinition, plot); -// ((VanChartPlot) plot).setCategoryNum(getFormualList().size() + 1); -// if (!getFormualList().isEmpty()) { -// plot.getDataSheet().setVisible(false); -// } + super.updateMoreCate(reportDefinition, plot); + ((VanChartPlot) plot).setCategoryNum(getFormualList().size() + 1); + if (!getFormualList().isEmpty()) { + plot.getDataSheet().setVisible(false); + } } protected void checkComponent() { - //todo@shine9.0 -// super.checkComponent(); -// checkBoxList(isSupportMultiCategory); + super.checkComponent(); + checkBoxList(isSupportMultiCategory); } private void checkBoxList(boolean isSupportMulticategory) { - //todo@shine9.0 -// if (getFormualList().size() != 0) { -// for (int i = 0; i < getFormualList().size(); i++) { -// getFormualList().get(i).setEnabled(isSupportMulticategory); -// } -// } + if (getFormualList().size() != 0) { + for (int i = 0; i < getFormualList().size(); i++) { + getFormualList().get(i).setEnabled(isSupportMulticategory); + } + } } } diff --git a/designer_chart/src/com/fr/plugin/chart/designer/data/VanChartMoreCateTableDataContentPane.java b/designer_chart/src/com/fr/plugin/chart/designer/data/VanChartMoreCateTableDataContentPane.java index f05775a673..1f485bc626 100644 --- a/designer_chart/src/com/fr/plugin/chart/designer/data/VanChartMoreCateTableDataContentPane.java +++ b/designer_chart/src/com/fr/plugin/chart/designer/data/VanChartMoreCateTableDataContentPane.java @@ -28,27 +28,24 @@ public class VanChartMoreCateTableDataContentPane extends CategoryPlotMoreCateTa } protected void updateMoreCate(NormalTableDataDefinition normal, Plot plot) { - //todo@shine9.0 -// super.updateMoreCate(normal, plot); -// ((VanChartPlot) plot).setCategoryNum(getBoxList().size() + 1); -// if (!getBoxList().isEmpty()) { -// plot.getDataSheet().setVisible(false); -// } + super.updateMoreCate(normal, plot); + ((VanChartPlot) plot).setCategoryNum(getBoxList().size() + 1); + if (!getBoxList().isEmpty()) { + plot.getDataSheet().setVisible(false); + } } protected void checkComponent() { - //todo@shine9.0 -// super.checkComponent(); -// checkBoxList(isSupportMultiCategory); + super.checkComponent(); + checkBoxList(isSupportMultiCategory); } private void checkBoxList(boolean isSupportMulticategory) { - //todo@shine9.0 -// if (getBoxList().size() != 0) { -// for (int i = 0; i < getBoxList().size(); i++) { -// getBoxList().get(i).setEnabled(isSupportMulticategory); -// } -// } + if (getBoxList().size() != 0) { + for (int i = 0; i < getBoxList().size(); i++) { + getBoxList().get(i).setEnabled(isSupportMulticategory); + } + } } }