From c9f7b304596a09b794f277f6c5626cf2a619d2e0 Mon Sep 17 00:00:00 2001 From: fr_shine Date: Mon, 8 Aug 2016 13:42:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=B0=E5=9B=BE=E5=8C=BA=E5=9F=9F=E7=BC=96?= =?UTF-8?q?=E8=BE=91=20=E8=BF=9C=E7=A8=8B=E4=B8=8B=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E9=9B=86=E5=8F=96=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../series/PlotSeries/MapCustomPane.java | 86 ++++++++++++------- .../PlotSeries/MapDefiAreaNamePane.java | 52 +++++------ 2 files changed, 77 insertions(+), 61 deletions(-) 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 0a922d34e..be5fdad60 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,37 +1,36 @@ package com.fr.design.chart.series.PlotSeries; -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -import javax.swing.JFileChooser; -import javax.swing.JPanel; -import javax.swing.SwingConstants; - +import com.fr.base.FRContext; +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; -import com.fr.data.TableDataSource; -import com.fr.data.core.DataCoreUtils; import com.fr.design.data.tabledata.wrapper.TableDataWrapper; -import com.fr.design.beans.BasicBeanPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icombobox.FilterComboBox; import com.fr.design.gui.ilable.BoldFontTextLabel; import com.fr.design.gui.ilable.UILabel; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.chart.gui.data.DatabaseTableDataPane; +import com.fr.general.ComparatorUtils; +import com.fr.general.GeneralUtils; import com.fr.general.Inter; +import com.fr.general.data.DataModel; import com.fr.stable.StringUtils; import org.apache.batik.swing.svg.SVGFileFilter; +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.io.File; +import java.util.ArrayList; +import java.util.List; + /** * 自定义地图界面. * @@ -131,22 +130,51 @@ refreshAreaNameBox(); String colName = Utils.objectToString(areaString.getSelectedItem()); TableDataWrapper tableDataWrappe = tableDataNameBox.getTableDataWrapper(); - TableDataSource source = DesignTableDataManager.getEditingTableDataSource(); - if (tableDataWrappe == null || source == null) { - return; - } - - String[] values = DataCoreUtils.getColValuesInData(source, tableDataWrappe.getTableDataName(), colName); - ArrayList list = new ArrayList(); - for(int i = 0; i < values.length; i++) { - list.add(values[i]); - } - imageShowPane.refreshFromDataList(list); + imageShowPane.refreshFromDataList(getColValuesInData(tableDataWrappe, colName)); } } }; + public static List getColValuesInData(TableDataWrapper tableDataWrappe, String colName) { + List colValues = new ArrayList<>(); + + EmbeddedTableData embeddedTableData = null; + try { + embeddedTableData = DesignTableDataManager.previewTableDataNotNeedInputParameters(tableDataWrappe.getTableData(), TableData.RESULT_ALL, false); + } catch (Exception ee) { + FRContext.getLogger().error(ee.getMessage(), ee); + } + + if(embeddedTableData == null){ + return colValues; + } + + int columnIndex = getColumnIndex(embeddedTableData, colName); + + if(columnIndex == DataModel.COLUMN_NAME_NOT_FOUND){ + return colValues; + } + + for (int rowIndex = 0, rowCount = embeddedTableData.getRowCount(); rowIndex < rowCount; rowIndex++) { + String colValueName = GeneralUtils.objectToString(embeddedTableData.getValueAt(rowIndex, columnIndex)); + if (!colValues.contains(colValueName)) { + colValues.add(colValueName); + } + } + + return colValues; + } + + private static int getColumnIndex(EmbeddedTableData tableData, String colName) { + for (int columnIndex = 0, columnCount = tableData.getColumnCount(); columnIndex < columnCount; columnIndex++) { + if (ComparatorUtils.tableDataColumnNameEquals(tableData.getColumnName(columnIndex), colName)) { + return columnIndex; + } + } + return DataModel.COLUMN_NAME_NOT_FOUND; + } + /** * 选中方式: 区域或者点 */ 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 515527eaf..b3cb2d811 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,43 +1,33 @@ package com.fr.design.chart.series.PlotSeries; -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import javax.swing.AbstractCellEditor; -import javax.swing.JPanel; -import javax.swing.JTable; -import javax.swing.SwingConstants; -import javax.swing.table.DefaultTableCellRenderer; -import javax.swing.table.TableCellEditor; - +import com.fr.base.Utils; import com.fr.chart.base.MapSvgAttr; import com.fr.chart.base.MapSvgXMLHelper; -import com.fr.base.Utils; -import com.fr.design.data.DesignTableDataManager; -import com.fr.data.TableDataSource; -import com.fr.data.core.DataCoreUtils; -import com.fr.design.data.tabledata.wrapper.TableDataWrapper; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.data.tabledata.wrapper.TableDataWrapper; +import com.fr.design.editor.ValueEditorPane; +import com.fr.design.editor.ValueEditorPaneFactory; +import com.fr.design.editor.editor.Editor; +import com.fr.design.editor.editor.TextEditor; import com.fr.design.gui.icombobox.FilterComboBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itableeditorpane.UIArrayTableModel; import com.fr.design.gui.itableeditorpane.UITableEditorPane; -import com.fr.design.mainframe.chart.gui.data.DatabaseTableDataPane; -import com.fr.design.editor.ValueEditorPane; -import com.fr.design.editor.ValueEditorPaneFactory; import com.fr.design.gui.xcombox.ComboBoxUseEditor; -import com.fr.design.editor.editor.Editor; -import com.fr.design.editor.editor.TextEditor; +import com.fr.design.mainframe.chart.gui.data.DatabaseTableDataPane; import com.fr.general.Inter; import com.fr.third.org.apache.poi.hssf.record.formula.functions.T; +import javax.swing.*; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.TableCellEditor; +import java.awt.*; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + /** * 地图, 定义区域名. * @@ -114,12 +104,10 @@ public class MapDefiAreaNamePane extends BasicBeanPane implements Abstrc String columnName = Utils.objectToString(columnBox.getSelectedItem()); TableDataWrapper tableDataWrappe = tableDataBox.getTableDataWrapper(); - TableDataSource source = DesignTableDataManager.getEditingTableDataSource(); - if (tableDataWrappe == null || source == null) { - return; - } - initNames = DataCoreUtils.getColValuesInData(source, tableDataWrappe.getTableDataName(), columnName); + List list = MapCustomPane.getColValuesInData(tableDataWrappe, columnName); + + initNames = list.toArray(initNames); if (tableEditorModel != null) { tableEditorModel.stopCellEditing();// 只是用来刷新列表的combox