package com.vci.client.workflow.editor.user;
|
|
import java.awt.BorderLayout;
|
import java.awt.Dimension;
|
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionListener;
|
import java.util.ArrayList;
|
import java.util.List;
|
|
import javax.swing.BoxLayout;
|
import javax.swing.JButton;
|
import javax.swing.JPanel;
|
import javax.swing.JScrollPane;
|
import javax.swing.JTable;
|
|
import com.vci.client.workflow.commom.ClientHelper;
|
import com.vci.corba.workflow.data.CustomInfo;
|
|
public class CustomEditPanel extends JPanel {
|
private static final long serialVersionUID = 1300418480939892949L;
|
|
private JTable customTable;
|
private JButton addBtn;
|
private JButton deleteBtn;
|
|
public CustomEditPanel() {
|
initUI();
|
addListener();
|
}
|
|
private void addListener() {
|
addBtn.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent e) {
|
CustomTableModel model = (CustomTableModel)customTable.getModel();
|
model.addRow();
|
}
|
});
|
|
deleteBtn.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent e) {
|
int[] selectedRows = customTable.getSelectedRows();
|
CustomTableModel model = (CustomTableModel)customTable.getModel();
|
model.deleteRow(selectedRows);
|
}
|
});
|
}
|
|
private void initUI() {
|
setLayout(new BorderLayout());
|
add(new JScrollPane(getCustomProperty()), BorderLayout.CENTER);
|
|
JPanel BtnPanel = new JPanel();
|
add(BtnPanel, BorderLayout.EAST);
|
BtnPanel.setLayout(new BoxLayout(BtnPanel, BoxLayout.Y_AXIS));
|
|
addBtn = new JButton("添加");
|
BtnPanel.add(addBtn);
|
|
deleteBtn = new JButton("删除");
|
BtnPanel.add(deleteBtn);
|
}
|
|
private JTable getCustomProperty() {
|
if(customTable == null) {
|
customTable = new JTable(new CustomTableModel());
|
customTable.setRowHeight(20);
|
|
Dimension size = customTable.getTableHeader().getPreferredSize();
|
size.height = 22;
|
customTable.getTableHeader().setPreferredSize(size);
|
|
// JComboBox c = new JComboBox();//在下拉列表中选择phase
|
// c.addItem("");
|
// c.addItem("phase");
|
// propertyTable.getColumnModel().getColumn(0).setCellEditor(new DefaultCellEditor(c));
|
}
|
return customTable;
|
}
|
|
public CustomInfo[] getCustomUserInfos(){
|
List<CustomInfo> result = new ArrayList<CustomInfo>();
|
CustomTableModel model = (CustomTableModel)customTable.getModel();
|
List<CustomInfo> data = model.getData();
|
if(data != null && data.size() > 0){
|
for (CustomInfo customInfo : data) {
|
if(customInfo ==null){
|
return result.toArray(new CustomInfo[0]);
|
}
|
if(customInfo.className.trim().length() > 0
|
&& customInfo.value.trim().length() > 0){
|
result.add(customInfo);
|
}
|
}
|
}
|
return result.toArray(new CustomInfo[0]);
|
}
|
|
public void setData(List<CustomInfo> data){
|
CustomTableModel model = (CustomTableModel)customTable.getModel();
|
model.setData(data);
|
}
|
|
private String getI18nString(String spCode) {
|
return ClientHelper.getI18nStringForWorkflow(this.getClass().getName() + "." + spCode, this.getLocale());
|
}
|
|
}
|