package com.vci.client.portal.NewUI;
|
|
import java.awt.BorderLayout;
|
import java.awt.Color;
|
import java.awt.Component;
|
|
import javax.swing.JButton;
|
import javax.swing.JPanel;
|
import javax.swing.JScrollPane;
|
import javax.swing.JTable;
|
import javax.swing.event.DocumentEvent;
|
import javax.swing.event.DocumentListener;
|
import javax.swing.table.DefaultTableCellRenderer;
|
import javax.swing.table.TableColumn;
|
|
import com.vci.client.LogonApplication;
|
import com.vci.client.common.VCIBasePanel;
|
import com.vci.client.framework.rightConfig.object.FunctionObject;
|
import com.vci.client.portal.utility.UITools;
|
import com.vci.client.ui.swing.VCIOptionPane;
|
import com.vci.client.ui.table.VCIBaseTableModel;
|
import com.vci.client.ui.table.VCIBaseTableNode;
|
import com.vci.corba.common.VCIError;
|
import com.vci.corba.portal.data.PLAction;
|
|
import java.awt.event.ActionListener;
|
import java.awt.event.ActionEvent;
|
import javax.swing.JLabel;
|
import java.awt.FlowLayout;
|
import javax.swing.JTextField;
|
|
/**
|
* Action管理
|
*/
|
public class ActionConfPanel extends VCIBasePanel {
|
|
/**
|
*
|
*/
|
private static final long serialVersionUID = 1L;
|
private JButton addBtn ;
|
private JButton editBtn ;
|
private JButton delBtn ;
|
private JPanel tablePanel;
|
private JScrollPane scrollPane;
|
private JTable actionTable;
|
private VCIBaseTableModel actionTableModel;
|
|
String[] headerName = new String[] {
|
"编号", "名称","类路径", "链接地址", "类型", "描述"
|
};
|
Class[] columnTypes = new Class[] {
|
String.class, String.class, String.class, String.class, String.class
|
};
|
private JPanel searchPanel;
|
private JLabel label;
|
private JTextField searchText;
|
private String searchValue ;
|
public ActionConfPanel(FunctionObject funcObj) {
|
super(funcObj);
|
init();
|
initActionListener();
|
initData();
|
}
|
|
private void init() {
|
setLayout(new BorderLayout(0, 0));
|
|
JPanel panel = new JPanel();
|
add(panel, BorderLayout.SOUTH);
|
|
addBtn = new JButton("新建");
|
panel.add(addBtn);
|
|
editBtn = new JButton("修改");
|
panel.add(editBtn);
|
|
delBtn = new JButton("删除");
|
panel.add(delBtn);
|
|
tablePanel = new JPanel();
|
add(tablePanel, BorderLayout.CENTER);
|
tablePanel.setLayout(new BorderLayout(0, 0));
|
|
scrollPane = new JScrollPane();
|
tablePanel.add(scrollPane);
|
|
actionTable = new JTable();
|
actionTableModel = new VCIBaseTableModel(headerName,columnTypes);
|
actionTable.setModel(actionTableModel);
|
scrollPane.setViewportView(actionTable);
|
|
searchPanel = new JPanel();
|
FlowLayout flowLayout = (FlowLayout) searchPanel.getLayout();
|
flowLayout.setAlignment(FlowLayout.LEFT);
|
add(searchPanel, BorderLayout.NORTH);
|
|
label = new JLabel("编号:");
|
searchPanel.add(label);
|
|
searchText = new JTextField();
|
searchPanel.add(searchText);
|
searchText.setColumns(10);
|
}
|
|
private void initData(){
|
actionTableModel.list.clear();
|
VCIBaseTableNode vciBaseTableNode = null;
|
try {
|
PLAction[] obj = UITools.getService().getAllPLAction();
|
for(int i =0;i<obj.length;i++){
|
vciBaseTableNode = new VCIBaseTableNode(obj[i]);
|
vciBaseTableNode.setPropertyValueByName(actionTable.getColumnName(0), obj[i].plCode);
|
vciBaseTableNode.setPropertyValueByName(actionTable.getColumnName(1), obj[i].plName);
|
vciBaseTableNode.setPropertyValueByName(actionTable.getColumnName(2), obj[i].plCSClass);
|
vciBaseTableNode.setPropertyValueByName(actionTable.getColumnName(3), obj[i].plBSUrl);
|
String plTypeType = obj[i].plTypeType;
|
String disType = "";
|
if(plTypeType.equals("business")){
|
disType = "业务类型";
|
}
|
else if(plTypeType.equals("link")){
|
disType = "链接类型";
|
}
|
vciBaseTableNode.setPropertyValueByName(actionTable.getColumnName(4), disType);
|
vciBaseTableNode.setPropertyValueByName(actionTable.getColumnName(5), obj[i].plDesc);
|
actionTableModel.addRow(i, vciBaseTableNode);
|
}
|
actionTable.setModel(actionTableModel);
|
setBanMaXian(actionTable);
|
actionTable.updateUI();
|
} catch (VCIError e) {
|
e.printStackTrace();
|
}
|
}
|
private void initSearchData(){
|
actionTableModel.list.clear();
|
VCIBaseTableNode vciBaseTableNode = null;
|
try {
|
PLAction[] obj = UITools.getService().getAllPLAction();
|
for(int i =0;i<obj.length;i++){
|
vciBaseTableNode = new VCIBaseTableNode(obj[i]);
|
if(obj[i].plCode.toLowerCase().contains(searchValue)){
|
vciBaseTableNode.setPropertyValueByName(actionTable.getColumnName(0), obj[i].plCode);
|
vciBaseTableNode.setPropertyValueByName(actionTable.getColumnName(1), obj[i].plName);
|
vciBaseTableNode.setPropertyValueByName(actionTable.getColumnName(2), obj[i].plCSClass);
|
vciBaseTableNode.setPropertyValueByName(actionTable.getColumnName(3), obj[i].plBSUrl);
|
String plTypeType = obj[i].plTypeType;
|
String disType = "";
|
if(plTypeType.equals("business")){
|
disType = "业务类型";
|
}
|
else if(plTypeType.equals("link")){
|
disType = "链接类型";
|
}
|
vciBaseTableNode.setPropertyValueByName(actionTable.getColumnName(4), disType);
|
vciBaseTableNode.setPropertyValueByName(actionTable.getColumnName(5), obj[i].plDesc);
|
actionTableModel.addRow(i, vciBaseTableNode);
|
}
|
}
|
actionTable.setModel(actionTableModel);
|
setBanMaXian(actionTable);
|
actionTable.updateUI();
|
} catch (VCIError e) {
|
e.printStackTrace();
|
}
|
}
|
|
//设置JTable斑马线效果
|
public void setBanMaXian(JTable table)
|
{
|
//斑马线设置
|
DefaultTableCellRenderer d = new DefaultTableCellRenderer()
|
{//需要重写类中的getTableCellRendererComponent的方法
|
@Override
|
public Component getTableCellRendererComponent(JTable table,
|
Object value, boolean isSelected, boolean hasFocus,
|
int row, int column)
|
{
|
if(row % 2 == 0)//JTable中的奇数行
|
{
|
setBackground(Color.WHITE);
|
}
|
else//JTable中的偶数行
|
{
|
setBackground(Color.LIGHT_GRAY);
|
}
|
return super.getTableCellRendererComponent(table, value, isSelected, hasFocus,
|
row, column);
|
}
|
};
|
for(int i = 0; i< table.getColumnCount();i++)
|
{
|
TableColumn col = table.getColumn(table.getColumnName(i));
|
col.setCellRenderer(d);//将斑马线对象放置到表格中
|
}
|
}
|
|
private void initActionListener(){
|
searchText.getDocument().addDocumentListener(new DocumentListener() {
|
|
@Override
|
public void removeUpdate(DocumentEvent arg0) {
|
searchValue = searchText.getText();
|
if(searchValue==null||"".equals(searchValue)){
|
initData();
|
}else{
|
initSearchData();
|
}
|
}
|
|
@Override
|
public void insertUpdate(DocumentEvent arg0) {
|
searchValue = searchText.getText();
|
if(searchValue==null||"".equals(searchValue)){
|
return;
|
}else{
|
initSearchData();
|
}
|
}
|
|
@Override
|
public void changedUpdate(DocumentEvent arg0) {
|
}
|
});
|
addBtn.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent arg0) {
|
ActionConfDialog dialog = new ActionConfDialog(null);
|
dialog.setVisible(true);
|
initData();
|
}
|
});
|
editBtn.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent arg0) {
|
int selectedRowCount = actionTable.getSelectedRowCount();
|
if(selectedRowCount==0){
|
VCIOptionPane.showMessage(LogonApplication.frame, "请选择一条数据!");
|
return;
|
}
|
int selectedRow = actionTable.getSelectedRow();
|
PLAction obj = (PLAction) actionTableModel.getValueAt(selectedRow).getObj();
|
|
ActionConfDialog dialog = new ActionConfDialog(obj);
|
dialog.setVisible(true);
|
initData();
|
}
|
});
|
delBtn.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent arg0) {
|
int selectedRowCount = actionTable.getSelectedRowCount();
|
if(selectedRowCount==0){
|
VCIOptionPane.showMessage(LogonApplication.frame, "请选择一条数据!");
|
return;
|
}
|
if (VCIOptionPane.showQuestion(LogonApplication.frame,
|
"确定要删除记录吗?") != 0) {
|
return;
|
}
|
int selectedRow = actionTable.getSelectedRow();
|
PLAction obj = (PLAction) actionTableModel.getValueAt(selectedRow).getObj();
|
try {
|
UITools.getService().deletePLAction(obj);
|
VCIOptionPane.showMessage(LogonApplication.frame, "删除成功!");
|
} catch (VCIError e) {
|
VCIOptionPane.showMessage(LogonApplication.frame, "删除失败!");
|
e.printStackTrace();
|
}
|
initData();
|
}
|
});
|
}
|
}
|