|
|
@ -2,13 +2,13 @@ package com.fr.design.data.tabledata.tabledatapane; |
|
|
|
|
|
|
|
|
|
|
|
import com.fine.theme.utils.FineUIScale; |
|
|
|
import com.fine.theme.utils.FineUIScale; |
|
|
|
import com.fr.data.impl.EmbeddedTableData; |
|
|
|
import com.fr.data.impl.EmbeddedTableData; |
|
|
|
|
|
|
|
import com.fr.design.constants.LayoutConstants; |
|
|
|
import com.fr.design.dialog.BasicDialog; |
|
|
|
import com.fr.design.dialog.BasicDialog; |
|
|
|
import com.fr.design.dialog.DialogActionAdapter; |
|
|
|
import com.fr.design.dialog.DialogActionAdapter; |
|
|
|
import com.fr.design.gui.date.UIDatePicker; |
|
|
|
import com.fr.design.gui.date.UIDatePicker; |
|
|
|
import com.fr.design.gui.ibutton.UIButton; |
|
|
|
import com.fr.design.gui.ibutton.UIButton; |
|
|
|
import com.fr.design.gui.icontainer.UITableScrollPane; |
|
|
|
import com.fr.design.gui.icontainer.UITableScrollPane; |
|
|
|
import com.fr.design.gui.ilable.UILabel; |
|
|
|
import com.fr.design.gui.ilable.UILabel; |
|
|
|
import com.fr.design.layout.FRGUIPaneFactory; |
|
|
|
|
|
|
|
import com.fr.design.mainframe.DesignerContext; |
|
|
|
import com.fr.design.mainframe.DesignerContext; |
|
|
|
import com.fr.general.DateUtils; |
|
|
|
import com.fr.general.DateUtils; |
|
|
|
import com.fr.log.FineLoggerFactory; |
|
|
|
import com.fr.log.FineLoggerFactory; |
|
|
@ -34,6 +34,10 @@ import java.awt.event.MouseEvent; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.Date; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import static com.fine.swing.ui.layout.Layouts.cell; |
|
|
|
|
|
|
|
import static com.fine.swing.ui.layout.Layouts.row; |
|
|
|
|
|
|
|
import static com.fine.swing.ui.layout.Layouts.column; |
|
|
|
|
|
|
|
import static com.fine.swing.ui.layout.Layouts.flex; |
|
|
|
|
|
|
|
|
|
|
|
public class EmbeddedTableDataPane extends AbstractTableDataPane<EmbeddedTableData> { |
|
|
|
public class EmbeddedTableDataPane extends AbstractTableDataPane<EmbeddedTableData> { |
|
|
|
private static final int MIN_CELL_WIDTH = 30; |
|
|
|
private static final int MIN_CELL_WIDTH = 30; |
|
|
@ -44,7 +48,6 @@ public class EmbeddedTableDataPane extends AbstractTableDataPane<EmbeddedTableDa |
|
|
|
private UILabel coordinatelabel; |
|
|
|
private UILabel coordinatelabel; |
|
|
|
private UIButton insertRowButton; |
|
|
|
private UIButton insertRowButton; |
|
|
|
private UIButton removeRowButton; |
|
|
|
private UIButton removeRowButton; |
|
|
|
private UIButton columnSetButton; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Constructor |
|
|
|
* Constructor |
|
|
@ -61,8 +64,7 @@ public class EmbeddedTableDataPane extends AbstractTableDataPane<EmbeddedTableDa |
|
|
|
// prepare the data in this way as default if no arguments is passed in
|
|
|
|
// prepare the data in this way as default if no arguments is passed in
|
|
|
|
EmbeddedTableModel tableModel = new EmbeddedTableModel(new EmbeddedTableData()); |
|
|
|
EmbeddedTableModel tableModel = new EmbeddedTableModel(new EmbeddedTableData()); |
|
|
|
dataJTable = new JTable(tableModel); |
|
|
|
dataJTable = new JTable(tableModel); |
|
|
|
scrollPane = new UITableScrollPane(dataJTable); |
|
|
|
scrollPane = new UITableScrollPane(dataJTable);; |
|
|
|
this.add(scrollPane, BorderLayout.CENTER); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 显示double,date类;渲染date类
|
|
|
|
// 显示double,date类;渲染date类
|
|
|
|
dataJTable.setDefaultRenderer(Double.class, new DoubleRenderer()); |
|
|
|
dataJTable.setDefaultRenderer(Double.class, new DoubleRenderer()); |
|
|
@ -80,21 +82,10 @@ public class EmbeddedTableDataPane extends AbstractTableDataPane<EmbeddedTableDa |
|
|
|
editbysingleclick(dataJTable, Integer.class); |
|
|
|
editbysingleclick(dataJTable, Integer.class); |
|
|
|
|
|
|
|
|
|
|
|
// AUTO RESIZE
|
|
|
|
// AUTO RESIZE
|
|
|
|
// dataJTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
|
|
|
|
|
|
|
|
dataJTable.setAutoResizeMode(tableModel.getColumnCount() * PREVIEW_TABLE_MIN_COLUMN_WIDTH <= PREVIEW_TABLE_WIDTH ? JTable.AUTO_RESIZE_ALL_COLUMNS : JTable.AUTO_RESIZE_OFF); |
|
|
|
dataJTable.setAutoResizeMode(tableModel.getColumnCount() * PREVIEW_TABLE_MIN_COLUMN_WIDTH <= PREVIEW_TABLE_WIDTH ? JTable.AUTO_RESIZE_ALL_COLUMNS : JTable.AUTO_RESIZE_OFF); |
|
|
|
dataJTable.setRowSelectionAllowed(true); |
|
|
|
dataJTable.setRowSelectionAllowed(true); |
|
|
|
dataJTable.setColumnSelectionAllowed(true); |
|
|
|
dataJTable.setColumnSelectionAllowed(true); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// peter:控制Panel
|
|
|
|
|
|
|
|
JPanel northPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); |
|
|
|
|
|
|
|
this.add(northPane, BorderLayout.NORTH); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// kel:在左上角加一个JLabel用来显示坐标,方便用户查看。
|
|
|
|
|
|
|
|
coordinatelabel = new UILabel("0/0,0/0"); |
|
|
|
|
|
|
|
coordinatelabel.setHorizontalAlignment(UILabel.CENTER); |
|
|
|
|
|
|
|
northPane.add(coordinatelabel); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dataJTable.addMouseListener(new MouseAdapter() { |
|
|
|
dataJTable.addMouseListener(new MouseAdapter() { |
|
|
|
public void mousePressed(MouseEvent e) { |
|
|
|
public void mousePressed(MouseEvent e) { |
|
|
|
// kel:加上一个鼠标点击的监控,鼠标点击时,返回选中的行坐标和列坐标。
|
|
|
|
// kel:加上一个鼠标点击的监控,鼠标点击时,返回选中的行坐标和列坐标。
|
|
|
@ -114,14 +105,17 @@ public class EmbeddedTableDataPane extends AbstractTableDataPane<EmbeddedTableDa |
|
|
|
checkButtonEnabled(); |
|
|
|
checkButtonEnabled(); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
initOtherNorthPaneComponents(northPane); |
|
|
|
this.add(column(LayoutConstants.VERTICAL_GAP, cell(getNorthPaneComponents()), cell(scrollPane).weight(1)).getComponent()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void initOtherNorthPaneComponents(JPanel northPane) { |
|
|
|
private JPanel getNorthPaneComponents() { |
|
|
|
|
|
|
|
// kel:在左上角加一个JLabel用来显示坐标,方便用户查看。
|
|
|
|
|
|
|
|
coordinatelabel = new UILabel("0/0,0/0"); |
|
|
|
|
|
|
|
coordinatelabel.setHorizontalAlignment(UILabel.CENTER); |
|
|
|
// 表结构设置
|
|
|
|
// 表结构设置
|
|
|
|
columnSetButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Embedded_Table_Design")); |
|
|
|
UIButton columnSetButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Embedded_Table_Design")); |
|
|
|
columnSetButton.setMnemonic('C'); |
|
|
|
columnSetButton.setMnemonic('C'); |
|
|
|
northPane.add(columnSetButton); |
|
|
|
|
|
|
|
columnSetButton.addActionListener(new ActionListener() { |
|
|
|
columnSetButton.addActionListener(new ActionListener() { |
|
|
|
public void actionPerformed(ActionEvent evt) { |
|
|
|
public void actionPerformed(ActionEvent evt) { |
|
|
|
|
|
|
|
|
|
|
@ -140,7 +134,6 @@ public class EmbeddedTableDataPane extends AbstractTableDataPane<EmbeddedTableDa |
|
|
|
dataJTable.repaint(); |
|
|
|
dataJTable.repaint(); |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
BasicDialog dlg = columnSetPane.showWindow(DesignerContext.getDesignerFrame(), l); |
|
|
|
BasicDialog dlg = columnSetPane.showWindow(DesignerContext.getDesignerFrame(), l); |
|
|
|
dlg.setAlwaysOnTop(true); |
|
|
|
dlg.setAlwaysOnTop(true); |
|
|
|
dlg.setVisible(true); |
|
|
|
dlg.setVisible(true); |
|
|
@ -150,7 +143,6 @@ public class EmbeddedTableDataPane extends AbstractTableDataPane<EmbeddedTableDa |
|
|
|
// DataSourceEditor-Insert_Row
|
|
|
|
// DataSourceEditor-Insert_Row
|
|
|
|
insertRowButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Utils_Insert_Row")); |
|
|
|
insertRowButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Utils_Insert_Row")); |
|
|
|
insertRowButton.setMnemonic('I'); |
|
|
|
insertRowButton.setMnemonic('I'); |
|
|
|
northPane.add(insertRowButton); |
|
|
|
|
|
|
|
insertRowButton.addActionListener(new ActionListener() { |
|
|
|
insertRowButton.addActionListener(new ActionListener() { |
|
|
|
public void actionPerformed(ActionEvent evt) { |
|
|
|
public void actionPerformed(ActionEvent evt) { |
|
|
|
insertRow(); |
|
|
|
insertRow(); |
|
|
@ -160,7 +152,6 @@ public class EmbeddedTableDataPane extends AbstractTableDataPane<EmbeddedTableDa |
|
|
|
// DataSourceEditor-Remove_Row
|
|
|
|
// DataSourceEditor-Remove_Row
|
|
|
|
removeRowButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Delete_Row")); |
|
|
|
removeRowButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Utils_Delete_Row")); |
|
|
|
removeRowButton.setMnemonic('R'); |
|
|
|
removeRowButton.setMnemonic('R'); |
|
|
|
northPane.add(removeRowButton); |
|
|
|
|
|
|
|
removeRowButton.addActionListener(new ActionListener() { |
|
|
|
removeRowButton.addActionListener(new ActionListener() { |
|
|
|
public void actionPerformed(ActionEvent evt) { |
|
|
|
public void actionPerformed(ActionEvent evt) { |
|
|
|
removeRow(); |
|
|
|
removeRow(); |
|
|
@ -169,6 +160,13 @@ public class EmbeddedTableDataPane extends AbstractTableDataPane<EmbeddedTableDa |
|
|
|
|
|
|
|
|
|
|
|
// 初始化时更新按钮状态
|
|
|
|
// 初始化时更新按钮状态
|
|
|
|
checkButtonEnabled(); |
|
|
|
checkButtonEnabled(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// peter:控制Panel
|
|
|
|
|
|
|
|
return row(LayoutConstants.VGAP_SMALL, |
|
|
|
|
|
|
|
cell(coordinatelabel), |
|
|
|
|
|
|
|
cell(columnSetButton), cell(insertRowButton), cell(removeRowButton), |
|
|
|
|
|
|
|
flex() |
|
|
|
|
|
|
|
).getComponent(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|