From c36843c67c77d0f61177d49092d463c3b3bdb572 Mon Sep 17 00:00:00 2001 From: zheng Date: Tue, 26 Jun 2018 11:58:25 +0800 Subject: [PATCH] =?UTF-8?q?CHART-2398=20=E9=85=8D=E7=BD=AE=E7=95=8C?= =?UTF-8?q?=E9=9D=A2=E5=8E=BB=E6=8E=89=E8=80=81=E5=9B=BE=E8=A1=A8=E5=AD=97?= =?UTF-8?q?=E6=A0=B7=20=E5=8A=9F=E8=83=BD=E7=82=B9=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E4=BF=9D=E7=95=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/ChartTypeInterfaceManager.java | 50 +++++++------------ .../mainframe/chart/gui/ChartTypePane.java | 30 ++++++----- 2 files changed, 36 insertions(+), 44 deletions(-) diff --git a/designer-chart/src/com/fr/design/ChartTypeInterfaceManager.java b/designer-chart/src/com/fr/design/ChartTypeInterfaceManager.java index a2d06362a..db01883af 100644 --- a/designer-chart/src/com/fr/design/ChartTypeInterfaceManager.java +++ b/designer-chart/src/com/fr/design/ChartTypeInterfaceManager.java @@ -275,26 +275,13 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr List priorityList = getPriorityInOrder(); for (Integer aPriorityList : priorityList) { String priority = String.valueOf(aPriorityList); - Iterator> chartUIIterator = chartTypeInterfaces.get(priority).entrySet().iterator(); - while (chartUIIterator.hasNext()) { - Map.Entry chartUIEntry = chartUIIterator.next(); - IndependentChartUIProvider provider = chartUIEntry.getValue(); - AbstractChartTypePane pane = provider.getPlotTypePane(); - pane.setPlotID(chartUIEntry.getKey()); - paneList.add(pane); - } + addPlotTypePaneList(priority, paneList); } } - private static String getChartName(String plotID, IndependentChartUIProvider provider) { - String name = provider.getPlotTypeTitle4PopupWindow(); - if (StringUtils.isEmpty(name)) { - name = ChartTypeManager.getInstance().getChartName(plotID); - } - return name; - } - private void addTitles(String priority, List list) { + public void addPlotTypePaneList(String priority, List> paneList) { + if (chartTypeInterfaces != null && chartTypeInterfaces.containsKey(priority)) { Map chartUIList = chartTypeInterfaces.get(priority); @@ -305,30 +292,31 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr String plotID = entry.getKey(); if (enabledChart(plotID)) { - list.add(getChartName(plotID, entry.getValue())); + AbstractChartTypePane pane = entry.getValue().getPlotTypePane(); + pane.setPlotID(plotID); + paneList.add(pane); } } } } - public String[] getTitle4PopupWindow() { - List priorityList = getPriorityInOrder(); - - List result = new ArrayList(); - for (Integer priority : priorityList) { - addTitles(String.valueOf(priority), result); + public void addPlotTypePaneList(List> paneList, + String priority, String plotID) { + if (chartTypeInterfaces != null && chartTypeInterfaces.containsKey(priority) && chartTypeInterfaces.get(priority).containsKey(plotID)) { + IndependentChartUIProvider provider = chartTypeInterfaces.get(priority).get(plotID); + AbstractChartTypePane pane = provider.getPlotTypePane(); + pane.setPlotID(plotID); + paneList.add(pane); } - - return result.toArray(new String[result.size()]); } - public String[] getTitle4PopupWindow(String priority) { - List list = new ArrayList(); - - addTitles(priority, list); - - return list.toArray(new String[list.size()]); + private static String getChartName(String plotID, IndependentChartUIProvider provider) { + String name = provider.getPlotTypeTitle4PopupWindow(); + if (StringUtils.isEmpty(name)) { + name = ChartTypeManager.getInstance().getChartName(plotID); + } + return name; } /** 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 961626ce3..d5435cf02 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 @@ -206,19 +206,30 @@ public class ChartTypePane extends AbstractChartAttrPane{ boolean enabledChart = ChartTypeManager.enabledChart(plotID); String item = ChartTypeInterfaceManager.getInstance().getTitle4PopupWindow(priority, plotID); - //第一步就是重构cardNames + //第一步就是重构cards + cards.clear(); if (enabledChart) { - cardNames = collection.getState() == SwitchState.DEFAULT - ? ChartTypeInterfaceManager.getInstance().getTitle4PopupWindow() - : ChartTypeInterfaceManager.getInstance().getTitle4PopupWindow(priority); + if (collection.getState() == SwitchState.DEFAULT) { + ChartTypeInterfaceManager.getInstance().addPlotTypePaneList(cards); + } else { + ChartTypeInterfaceManager.getInstance().addPlotTypePaneList(priority, cards); + } } else { - cardNames = new String[]{item}; + ChartTypeInterfaceManager.getInstance().addPlotTypePaneList(cards, priority, plotID); } //下拉框重构开始。为了防止重构是触发update ((FlexibleComboBox)jcb).setItemEvenType(ItemEventType.REACTOR); //重构下拉框选项 - reactorComboBox(); + cardNames = new String[cards.size()]; + cardPane.removeAll(); + jcb.removeAllItems(); + for (int i = 0; i < this.cards.size(); i++) { + String name = this.cards.get(i).title4PopupWindow();// Name从各自的pane里面获取 + cardNames[i] = name; + cardPane.add(this.cards.get(i), cardNames[i]); + addComboBoxItem(cards, i); + } //重新选择选中的下拉项 jcb.setSelectedItem(item); jcb.setEnabled(enabledChart); @@ -233,13 +244,6 @@ public class ChartTypePane extends AbstractChartAttrPane{ cl.show(cardPane, cardNames[jcb.getSelectedIndex()]); } - private void reactorComboBox() { - jcb.removeAllItems(); - for (int i = 0; i < this.cardNames.length; i++) { - jcb.addItem(cardNames[i]); - } - } - @Override public void populateBean(Chart ob) { for (int i = 0; i < this.cards.size(); i++) {