|
|
@ -9,6 +9,8 @@ import com.fr.design.data.DesignTableDataManager; |
|
|
|
import com.fr.design.data.tabledata.wrapper.TableDataWrapper; |
|
|
|
import com.fr.design.data.tabledata.wrapper.TableDataWrapper; |
|
|
|
import com.fr.design.gui.ibutton.UIButton; |
|
|
|
import com.fr.design.gui.ibutton.UIButton; |
|
|
|
import com.fr.design.gui.icombobox.FilterComboBox; |
|
|
|
import com.fr.design.gui.icombobox.FilterComboBox; |
|
|
|
|
|
|
|
import com.fr.design.gui.ifilechooser.FileChooserProvider; |
|
|
|
|
|
|
|
import com.fr.design.gui.ifilechooser.JavaFxNativeFileChooser; |
|
|
|
import com.fr.design.gui.ilable.BoldFontTextLabel; |
|
|
|
import com.fr.design.gui.ilable.BoldFontTextLabel; |
|
|
|
import com.fr.design.gui.ilable.UILabel; |
|
|
|
import com.fr.design.gui.ilable.UILabel; |
|
|
|
import com.fr.design.mainframe.DesignerContext; |
|
|
|
import com.fr.design.mainframe.DesignerContext; |
|
|
@ -40,56 +42,56 @@ import java.awt.event.ItemListener; |
|
|
|
* @author kunsnat E-mail:kunsnat@gmail.com |
|
|
|
* @author kunsnat E-mail:kunsnat@gmail.com |
|
|
|
* @version 创建时间:2012-10-15 下午03:38:15 |
|
|
|
* @version 创建时间:2012-10-15 下午03:38:15 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class MapCustomPane extends BasicBeanPane<String> implements AbstrctMapAttrEditPane{ // 储存地图对应的字段. 名称, 类型. shape (点 用圆形代替)
|
|
|
|
public class MapCustomPane extends BasicBeanPane<String> implements AbstrctMapAttrEditPane { // 储存地图对应的字段. 名称, 类型. shape (点 用圆形代替)
|
|
|
|
|
|
|
|
|
|
|
|
private FilterComboBox<String> areaString;// 区域字段
|
|
|
|
private FilterComboBox<String> areaString;// 区域字段
|
|
|
|
private DatabaseTableDataPane tableDataNameBox;// 数据集名称 + 后面跟随预览按钮
|
|
|
|
private DatabaseTableDataPane tableDataNameBox;// 数据集名称 + 后面跟随预览按钮
|
|
|
|
private MapImageEditPane imageShowPane; // 图片展示编辑的界面
|
|
|
|
private MapImageEditPane imageShowPane; // 图片展示编辑的界面
|
|
|
|
private String lastSelectPath; |
|
|
|
private String lastSelectPath; |
|
|
|
private boolean isNeedDataSource = true; |
|
|
|
private boolean isNeedDataSource = true; |
|
|
|
|
|
|
|
|
|
|
|
public MapCustomPane() { |
|
|
|
public MapCustomPane() { |
|
|
|
initComp(); |
|
|
|
initComp(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public MapCustomPane(boolean isNeedDataSource){ |
|
|
|
public MapCustomPane(boolean isNeedDataSource) { |
|
|
|
this.isNeedDataSource = isNeedDataSource; |
|
|
|
this.isNeedDataSource = isNeedDataSource; |
|
|
|
initComp(); |
|
|
|
initComp(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initComp() { |
|
|
|
private void initComp() { |
|
|
|
this.setLayout(new BorderLayout(0, 0)); |
|
|
|
this.setLayout(new BorderLayout(0, 0)); |
|
|
|
|
|
|
|
|
|
|
|
JPanel pane = new JPanel(); |
|
|
|
JPanel pane = new JPanel(); |
|
|
|
this.add(pane, BorderLayout.NORTH); |
|
|
|
this.add(pane, BorderLayout.NORTH); |
|
|
|
|
|
|
|
|
|
|
|
pane.setLayout(new BorderLayout()); |
|
|
|
pane.setLayout(new BorderLayout()); |
|
|
|
|
|
|
|
|
|
|
|
pane.add(northPaneCreate(), BorderLayout.NORTH); |
|
|
|
pane.add(northPaneCreate(), BorderLayout.NORTH); |
|
|
|
|
|
|
|
|
|
|
|
imageShowPane = new MapImageEditPane(); |
|
|
|
imageShowPane = new MapImageEditPane(); |
|
|
|
|
|
|
|
|
|
|
|
pane.add(imageShowPane, BorderLayout.CENTER); |
|
|
|
pane.add(imageShowPane, BorderLayout.CENTER); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private JPanel northPaneCreate() { |
|
|
|
private JPanel northPaneCreate() { |
|
|
|
JPanel northPane = new JPanel(); |
|
|
|
JPanel northPane = new JPanel(); |
|
|
|
|
|
|
|
|
|
|
|
northPane.setLayout(new FlowLayout(FlowLayout.LEFT)); |
|
|
|
northPane.setLayout(new FlowLayout(FlowLayout.LEFT)); |
|
|
|
|
|
|
|
|
|
|
|
UIButton loadMap = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Import_Map")); |
|
|
|
UIButton loadMap = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Import_Map")); |
|
|
|
loadMap.setPreferredSize(new Dimension(160, 20)); |
|
|
|
loadMap.setPreferredSize(new Dimension(160, 20)); |
|
|
|
northPane.add(loadMap); |
|
|
|
northPane.add(loadMap); |
|
|
|
|
|
|
|
|
|
|
|
loadMap.addActionListener(selectPictureActionListener); |
|
|
|
loadMap.addActionListener(selectPictureActionListener); |
|
|
|
|
|
|
|
|
|
|
|
if(isNeedDataSource){ |
|
|
|
if (isNeedDataSource) { |
|
|
|
UILabel label =new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Table_Data") + ":", SwingConstants.RIGHT) ; |
|
|
|
UILabel label = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Table_Data") + ":", SwingConstants.RIGHT); |
|
|
|
|
|
|
|
|
|
|
|
tableDataNameBox = new DatabaseTableDataPane(label) { |
|
|
|
tableDataNameBox = new DatabaseTableDataPane(label) { |
|
|
|
protected void userEvent() { |
|
|
|
protected void userEvent() { |
|
|
|
refreshAreaNameBox(); |
|
|
|
refreshAreaNameBox(); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
tableDataNameBox.setPreferredSize(new Dimension(200, 20)); |
|
|
|
tableDataNameBox.setPreferredSize(new Dimension(200, 20)); |
|
|
|
northPane.add(tableDataNameBox); |
|
|
|
northPane.add(tableDataNameBox); |
|
|
@ -100,158 +102,156 @@ refreshAreaNameBox(); |
|
|
|
areaString.setPreferredSize(new Dimension(120, 20)); |
|
|
|
areaString.setPreferredSize(new Dimension(120, 20)); |
|
|
|
areaString.addItemListener(areaChange); |
|
|
|
areaString.addItemListener(areaChange); |
|
|
|
northPane.add(areaString); |
|
|
|
northPane.add(areaString); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return northPane; |
|
|
|
return northPane; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private ActionListener selectPictureActionListener = new ActionListener() { |
|
|
|
private ActionListener selectPictureActionListener = new ActionListener() { |
|
|
|
|
|
|
|
|
|
|
|
public void actionPerformed(ActionEvent evt) { |
|
|
|
public void actionPerformed(ActionEvent evt) { |
|
|
|
JFileChooser svgFileChooser = new JFileChooser(); |
|
|
|
FileChooserProvider fileChooserProvider = new JavaFxNativeFileChooser.Builder(). |
|
|
|
svgFileChooser.addChoosableFileFilter(new SVGFileFilter()); |
|
|
|
filter(".svg, .svgz", "*.svg", "*.svgz"). |
|
|
|
if (StringUtils.isNotBlank(lastSelectPath)) { |
|
|
|
currentDirectory(lastSelectPath).build(); |
|
|
|
svgFileChooser.setSelectedFile(new File(lastSelectPath)); |
|
|
|
int returnVal = fileChooserProvider.showDialog(DesignerContext.getDesignerFrame()); |
|
|
|
} |
|
|
|
if (returnVal != JFileChooser.CANCEL_OPTION) { |
|
|
|
int returnVal = svgFileChooser.showOpenDialog(DesignerContext.getDesignerFrame()); |
|
|
|
File selectedFile = fileChooserProvider.getSelectedFile(); |
|
|
|
if (returnVal != JFileChooser.CANCEL_OPTION) { |
|
|
|
try { |
|
|
|
File selectedFile = svgFileChooser.getSelectedFile(); |
|
|
|
lastSelectPath = selectedFile.getCanonicalPath(); |
|
|
|
try { |
|
|
|
} catch (Exception ex) { |
|
|
|
lastSelectPath = selectedFile.getCanonicalPath(); |
|
|
|
FineLoggerFactory.getLogger().error(ex.getMessage(), ex); |
|
|
|
} catch (Exception ex) { |
|
|
|
} |
|
|
|
FineLoggerFactory.getLogger().error(ex.getMessage(), ex); |
|
|
|
if (selectedFile != null && selectedFile.isFile()) { |
|
|
|
} |
|
|
|
|
|
|
|
if (selectedFile != null && selectedFile.isFile()) { |
|
|
|
|
|
|
|
imageShowPane.setSvgMap(selectedFile.getPath()); |
|
|
|
imageShowPane.setSvgMap(selectedFile.getPath()); |
|
|
|
imageShowPane.repaint(); |
|
|
|
imageShowPane.repaint(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
private ItemListener areaChange = new ItemListener() { |
|
|
|
private ItemListener areaChange = new ItemListener() { |
|
|
|
public void itemStateChanged(ItemEvent e) { |
|
|
|
public void itemStateChanged(ItemEvent e) { |
|
|
|
Object select = areaString.getSelectedItem(); |
|
|
|
Object select = areaString.getSelectedItem(); |
|
|
|
if (select != null) { |
|
|
|
if (select != null) { |
|
|
|
String colName = Utils.objectToString(areaString.getSelectedItem()); |
|
|
|
String colName = Utils.objectToString(areaString.getSelectedItem()); |
|
|
|
|
|
|
|
|
|
|
|
TableDataWrapper tableDataWrappe = tableDataNameBox.getTableDataWrapper(); |
|
|
|
TableDataWrapper tableDataWrappe = tableDataNameBox.getTableDataWrapper(); |
|
|
|
|
|
|
|
|
|
|
|
imageShowPane.refreshFromDataList(getColValuesInData(tableDataWrappe, colName)); |
|
|
|
imageShowPane.refreshFromDataList(getColValuesInData(tableDataWrappe, colName)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
public static List<String> getColValuesInData(TableDataWrapper tableDataWrappe, String colName) { |
|
|
|
public static List<String> getColValuesInData(TableDataWrapper tableDataWrappe, String colName) { |
|
|
|
List<String> colValues = new ArrayList<>(); |
|
|
|
List<String> colValues = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
EmbeddedTableData embeddedTableData = null; |
|
|
|
EmbeddedTableData embeddedTableData = null; |
|
|
|
try { |
|
|
|
try { |
|
|
|
embeddedTableData = DesignTableDataManager.previewTableDataNotNeedInputParameters(tableDataWrappe.getTableData(), TableData.RESULT_ALL, false); |
|
|
|
embeddedTableData = DesignTableDataManager.previewTableDataNotNeedInputParameters(tableDataWrappe.getTableData(), TableData.RESULT_ALL, false); |
|
|
|
} catch (Exception ee) { |
|
|
|
} catch (Exception ee) { |
|
|
|
FineLoggerFactory.getLogger().error(ee.getMessage(), ee); |
|
|
|
FineLoggerFactory.getLogger().error(ee.getMessage(), ee); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if(embeddedTableData == null){ |
|
|
|
if (embeddedTableData == null) { |
|
|
|
return colValues; |
|
|
|
return colValues; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int columnIndex = getColumnIndex(embeddedTableData, colName); |
|
|
|
int columnIndex = getColumnIndex(embeddedTableData, colName); |
|
|
|
|
|
|
|
|
|
|
|
if(columnIndex == DataModel.COLUMN_NAME_NOT_FOUND){ |
|
|
|
if (columnIndex == DataModel.COLUMN_NAME_NOT_FOUND) { |
|
|
|
return colValues; |
|
|
|
return colValues; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (int rowIndex = 0, rowCount = embeddedTableData.getRowCount(); rowIndex < rowCount; rowIndex++) { |
|
|
|
for (int rowIndex = 0, rowCount = embeddedTableData.getRowCount(); rowIndex < rowCount; rowIndex++) { |
|
|
|
String colValueName = GeneralUtils.objectToString(embeddedTableData.getValueAt(rowIndex, columnIndex)); |
|
|
|
String colValueName = GeneralUtils.objectToString(embeddedTableData.getValueAt(rowIndex, columnIndex)); |
|
|
|
if (!colValues.contains(colValueName)) { |
|
|
|
if (!colValues.contains(colValueName)) { |
|
|
|
colValues.add(colValueName); |
|
|
|
colValues.add(colValueName); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return colValues; |
|
|
|
return colValues; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static int getColumnIndex(EmbeddedTableData tableData, String colName) { |
|
|
|
private static int getColumnIndex(EmbeddedTableData tableData, String colName) { |
|
|
|
for (int columnIndex = 0, columnCount = tableData.getColumnCount(); columnIndex < columnCount; columnIndex++) { |
|
|
|
for (int columnIndex = 0, columnCount = tableData.getColumnCount(); columnIndex < columnCount; columnIndex++) { |
|
|
|
if (ComparatorUtils.tableDataColumnNameEquals(tableData.getColumnName(columnIndex), colName)) { |
|
|
|
if (ComparatorUtils.tableDataColumnNameEquals(tableData.getColumnName(columnIndex), colName)) { |
|
|
|
return columnIndex; |
|
|
|
return columnIndex; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return DataModel.COLUMN_NAME_NOT_FOUND; |
|
|
|
return DataModel.COLUMN_NAME_NOT_FOUND; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 选中方式: 区域或者点 |
|
|
|
* 选中方式: 区域或者点 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void setImageSelectType(int selectType) { |
|
|
|
public void setImageSelectType(int selectType) { |
|
|
|
if (imageShowPane != null) { |
|
|
|
if (imageShowPane != null) { |
|
|
|
imageShowPane.setEditType(selectType); |
|
|
|
imageShowPane.setEditType(selectType); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void refreshAreaNameBox() {// 刷新区域名称列表
|
|
|
|
private void refreshAreaNameBox() {// 刷新区域名称列表
|
|
|
|
if(!isNeedDataSource){ |
|
|
|
if (!isNeedDataSource) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
TableDataWrapper tableDataWrappe = tableDataNameBox.getTableDataWrapper(); |
|
|
|
TableDataWrapper tableDataWrappe = tableDataNameBox.getTableDataWrapper(); |
|
|
|
if (tableDataWrappe == null) { |
|
|
|
if (tableDataWrappe == null) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
List<String> columnNameList = tableDataWrappe.calculateColumnNameList(); |
|
|
|
List<String> columnNameList = tableDataWrappe.calculateColumnNameList(); |
|
|
|
|
|
|
|
|
|
|
|
Object oldSelected = areaString.getSelectedItem(); |
|
|
|
Object oldSelected = areaString.getSelectedItem(); |
|
|
|
areaString.removeAllItems(); |
|
|
|
areaString.removeAllItems(); |
|
|
|
|
|
|
|
|
|
|
|
for(String item : columnNameList) { |
|
|
|
for (String item : columnNameList) { |
|
|
|
areaString.addItem(item); |
|
|
|
areaString.addItem(item); |
|
|
|
} |
|
|
|
} |
|
|
|
areaString.getModel().setSelectedItem(oldSelected); |
|
|
|
areaString.getModel().setSelectedItem(oldSelected); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 当前正在编辑的条目的类别(国家,省市)名和地图名 |
|
|
|
* 当前正在编辑的条目的类别(国家,省市)名和地图名 |
|
|
|
* @param typeName 类别名 |
|
|
|
* @param typeName 类别名 |
|
|
|
* @param mapName 地图名 |
|
|
|
* @param mapName 地图名 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void setTypeNameAndMapName(String typeName, String mapName){ |
|
|
|
public void setTypeNameAndMapName(String typeName, String mapName) { |
|
|
|
imageShowPane.setTypeNameAndMapName(typeName, mapName); |
|
|
|
imageShowPane.setTypeNameAndMapName(typeName, mapName); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 根据地图名称 加载信息 |
|
|
|
* 根据地图名称 加载信息 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void populateBean(String list) { |
|
|
|
public void populateBean(String list) { |
|
|
|
imageShowPane.populateBean(list); |
|
|
|
imageShowPane.populateBean(list); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 根据地图名称 保存信息 |
|
|
|
* 根据地图名称 保存信息 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public String updateBean() { |
|
|
|
public String updateBean() { |
|
|
|
// 地图类型等 加入Helper
|
|
|
|
// 地图类型等 加入Helper
|
|
|
|
return imageShowPane.updateBean(); |
|
|
|
return imageShowPane.updateBean(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected String title4PopupWindow() { |
|
|
|
protected String title4PopupWindow() { |
|
|
|
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom_Map"); |
|
|
|
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom_Map"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 更新界面 |
|
|
|
* 更新界面 |
|
|
|
* @param attr 地图属性 |
|
|
|
* @param attr 地图属性 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void populateMapAttr(MapSvgAttr attr) { |
|
|
|
public void populateMapAttr(MapSvgAttr attr) { |
|
|
|
imageShowPane.populateMapSvgAttr(attr); |
|
|
|
imageShowPane.populateMapSvgAttr(attr); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 更新MapSvgAttr |
|
|
|
* 更新MapSvgAttr |
|
|
|
* @return 返回属性 |
|
|
|
* @return 返回属性 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public MapSvgAttr updateCurrentAttr() { |
|
|
|
public MapSvgAttr updateCurrentAttr() { |
|
|
|
return imageShowPane.updateWithOutSave(); |
|
|
|
return imageShowPane.updateWithOutSave(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |