package com.vci.client.framework.systemConfig.stafforgmanage;
|
|
import java.awt.BorderLayout;
|
import java.awt.Dimension;
|
import java.awt.FlowLayout;
|
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionListener;
|
import java.util.ArrayList;
|
import java.util.HashMap;
|
import java.util.LinkedHashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
import javax.swing.JComboBox;
|
import javax.swing.JLabel;
|
import javax.swing.JPanel;
|
import javax.swing.JTextField;
|
import javax.swing.border.TitledBorder;
|
|
import com.vci.client.ClientSession;
|
import com.vci.client.LogonApplication;
|
import com.vci.client.common.VCIBasePanel;
|
import com.vci.client.framework.delegate.UserEntityClientDelegate;
|
import com.vci.client.framework.rightConfig.object.FunctionObject;
|
import com.vci.client.framework.util.RightControlUtil;
|
import com.vci.client.omd.enumManager.ui.EnumClient;
|
import com.vci.client.ui.swing.KJButton;
|
import com.vci.client.ui.swing.VCIOptionPane;
|
import com.vci.client.ui.swing.VCISwingUtil;
|
import com.vci.client.ui.swing.components.VCIJButton;
|
import com.vci.client.ui.swing.components.VCIJPanel;
|
import com.vci.client.ui.swing.components.table.AbstractVCIJTableDataProvider;
|
import com.vci.client.ui.swing.components.table.VCIJTableNode;
|
import com.vci.client.ui.swing.components.table.VCIJTablePanel;
|
import com.vci.common.locale.LocaleDisplay;
|
import com.vci.corba.common.VCIError;
|
import com.vci.corba.framework.data.MachSecurityInfo;
|
import com.vci.corba.omd.etm.EnumChild;
|
import com.vci.corba.omd.etm.EnumItem;
|
import com.vci.corba.common.data.UserEntityInfo;
|
|
public class MachSecurityPanel extends VCIBasePanel {
|
|
/**
|
*
|
*/
|
private static final long serialVersionUID = 4519009449023058267L;
|
private static final String ENUM_SECURITYGRADE = "Enumsecretgrade";
|
|
private Map<Short, String> mapSecurityEnum = new HashMap<Short, String>();
|
private Map<String, Short> mapSecurityValue = new HashMap<String, Short>();
|
|
// {{ 查询区控件
|
private JLabel nameLabel = new JLabel("机器名");
|
private JTextField nameText = new JTextField();
|
private JLabel ipLabel = new JLabel("IP地址");
|
private JTextField ipText = new JTextField();
|
private JLabel securityLabel = new JLabel("密级");
|
private JComboBox securityCombo = new JComboBox();
|
private KJButton searchButton = new KJButton("查询","search.png");
|
// }}
|
|
private VCIJButton addButton = VCISwingUtil.createVCIJButton("",
|
LocaleDisplay.getI18nString("rmip.stafforg.operate.add", "RMIPFramework", getLocale()),
|
LocaleDisplay.getI18nString("rmip.stafforg.operate.add", "RMIPFramework", getLocale()), "create.gif", null);
|
private VCIJButton editButton = VCISwingUtil.createVCIJButton("",
|
LocaleDisplay.getI18nString("rmip.stafforg.operate.modify", "RMIPFramework", getLocale()),
|
LocaleDisplay.getI18nString("rmip.stafforg.operate.modify", "RMIPFramework", getLocale()), "modify.gif",
|
null);
|
private VCIJButton deleteButton = VCISwingUtil.createVCIJButton("",
|
LocaleDisplay.getI18nString("rmip.stafforg.operate.delete", "RMIPFramework", getLocale()),
|
LocaleDisplay.getI18nString("rmip.stafforg.operate.delete", "RMIPFramework", getLocale()), "delete.gif",
|
null);
|
private VCIJButton importButton = VCISwingUtil.createVCIJButton("", "导入", "导入", "usertask.gif", null);
|
|
public MachSecurityPanel(FunctionObject funcObj) {
|
super(funcObj);
|
init();
|
}
|
|
public void refreshTableData() {
|
tablePanel.refreshTableData();
|
}
|
|
private void init() {
|
LogonApplication.getUserEntityObject().setModules(this.getModuleName());
|
|
initSecurityMap();
|
|
initComponents();
|
initAction();// 初始化按钮点击事件
|
}
|
|
/**
|
* @throws VCIError
|
*/
|
private void initSecurityMap() {
|
try {
|
securityCombo.addItem("");
|
EnumItem item = EnumClient.getService().getEmItemByName(ENUM_SECURITYGRADE);
|
|
for (EnumChild child : item.children) {
|
securityCombo.addItem(child.name);
|
Short value = Short.valueOf(child.value);
|
mapSecurityEnum.put(value, child.name);
|
mapSecurityValue.put(child.name, value);
|
}
|
} catch (VCIError e) {
|
e.printStackTrace();
|
}
|
}
|
|
private String getModuleName() {
|
// TODO Auto-generated method stub
|
return "机器密级管理";
|
}
|
|
private void initComponents() {
|
setLayout(new BorderLayout());
|
add(initTablePanel(), BorderLayout.CENTER);
|
}
|
|
/**
|
* 事件
|
*/
|
private void initAction() {
|
addButton.addActionListener(new java.awt.event.ActionListener() {
|
public void actionPerformed(ActionEvent e) {
|
addButton_conform();
|
}
|
});
|
|
editButton.addActionListener(new java.awt.event.ActionListener() {
|
public void actionPerformed(ActionEvent e) {
|
editButton_conform();
|
}
|
});
|
|
deleteButton.addActionListener(new java.awt.event.ActionListener() {
|
public void actionPerformed(ActionEvent e) {
|
deleteButton_conform();
|
}
|
});
|
|
importButton.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent e) {
|
ImportData();
|
tablePanel.refreshTableData(); // 刷新界面
|
}
|
});
|
}
|
|
/**
|
* 搜索事件
|
*/
|
private void searchButton_actionPerformed(){
|
SearchCondition condition = new SearchCondition();
|
condition.setName(nameText.getText().trim());
|
condition.setIpAddress(ipText.getText().trim());
|
condition.setSecurity(this.getSecurity());
|
|
dataProvider.setSearchInfos(condition);
|
|
this.tablePanel.refreshTableData();
|
}
|
|
|
private short getSecurity() {
|
Object obj = securityCombo.getSelectedItem();
|
if (obj == null)
|
return 0;
|
|
String selItem = obj.toString();
|
if (mapSecurityValue.containsKey(selItem))
|
return mapSecurityValue.get(selItem);
|
|
return 0;
|
}
|
|
/**
|
* 添加事件
|
*/
|
private void addButton_conform() {
|
MachSecurityInfo obj = new MachSecurityInfo();
|
new MachSecurityDialog(this, obj, MachSecurityDialog.OptionType.Add);
|
}
|
|
/**
|
* 修改事件
|
*/
|
private void editButton_conform() {
|
|
int len = tablePanel.getSelectedRowIndexs().length;
|
if (len == 0) {
|
VCIOptionPane.showMessage(this, "请选择需要编辑对象再进行修改操作!");
|
return;
|
}
|
if (len > 1) {
|
VCIOptionPane.showMessage(this,
|
LocaleDisplay.getI18nString("rmip.stafforg.operate.deptedit2", "RMIPFramework", getLocale()));
|
return;
|
}
|
MachSecurityInfo obj = tablePanel.getSelectedRowObjects().get(0);
|
|
new MachSecurityDialog(this, obj, MachSecurityDialog.OptionType.Edit);
|
}
|
|
/**
|
* 删除事件
|
*
|
* @throws VCIError
|
*/
|
private void deleteButton_conform() {
|
int len = tablePanel.getSelectedRowIndexs().length;
|
if (len == 0) {
|
VCIOptionPane.showMessage(this, "请选择要删除的对象!");
|
return;
|
}
|
String[] ids = new String[len];
|
|
Map<String, String> map = new HashMap<String, String>();
|
for (int i = 0; i < len; i++) {
|
MachSecurityInfo obj = tablePanel.getSelectedRowObjects().get(i);
|
ids[i] = obj.id;
|
map.put(obj.id, obj.name);
|
}
|
|
int ok = VCIOptionPane.showQuestion(LogonApplication.frame,
|
LocaleDisplay.getI18nString("rmip.stafforg.operate.conformdelrole", "RMIPFramework", getLocale()));
|
|
if (ok == 0) {
|
boolean rs = true;
|
try {
|
UserEntityInfo userInfo = UserEntityClientDelegate
|
.changeUserEntityToInfo(LogonApplication.getUserEntityObject());
|
|
rs = ClientSession.getFrameworkService().deletMachSecurity(ids, userInfo);
|
} catch (VCIError e) {
|
VCIOptionPane.showError(LogonApplication.frame, e);
|
return;
|
}
|
|
if (!rs) {
|
return;
|
}
|
} else {
|
return;
|
}
|
tablePanel.refreshTableData();
|
}
|
|
private void ImportData() {
|
MachSecurityImportDialog dialog = new MachSecurityImportDialog();
|
//eid.setLocationRelativeTo(ClientContextVariable.getFrame());
|
//dialog.setVisible(true);
|
}
|
|
private void checkPermission() {
|
checkRight(RightControlUtil.CREATE, addButton);
|
checkRight(RightControlUtil.UPDATE, editButton);
|
checkRight(RightControlUtil.DELETE, deleteButton);
|
checkRight(RightControlUtil.IMPORT, importButton);
|
}
|
|
|
|
private JPanel initTablePanel() {
|
|
JPanel pal = new JPanel();
|
pal.setLayout(new BorderLayout());
|
pal.setBorder(new TitledBorder("机器密级管理"));
|
pal.add(createQueryPanel(), BorderLayout.NORTH);
|
pal.add(createTablePanel(), BorderLayout.CENTER);
|
pal.setVisible(true);
|
return pal;
|
}
|
|
class MSDataProvider extends AbstractVCIJTableDataProvider<MachSecurityInfo> {
|
private SearchCondition condition = new SearchCondition();
|
|
public SearchCondition getSearchInfos() {
|
return condition;
|
}
|
|
public void setSearchInfos(SearchCondition condition) {
|
this.condition = condition;
|
}
|
|
@Override
|
public MachSecurityInfo[] getDatas(int pageNo, int pageSize) {
|
MachSecurityInfo[] infos = null;
|
try {
|
//infos = ClientSession.getFrameworkService().fetchMachSecurityByPage(pageNo, pageSize);
|
infos = ClientSession.getFrameworkService().fetchMachSecurityConditionByPage(condition.getName(),
|
condition.getIpAddress(), condition.getSecurity(), pageNo, pageSize);
|
|
} catch (VCIError e) {
|
VCIOptionPane.showError(LogonApplication.frame, e);
|
return null;
|
}
|
return infos;
|
}
|
|
@Override
|
public VCIJTableNode<MachSecurityInfo> getNewRowNode(MachSecurityInfo obj) {
|
VCIJTableNode<MachSecurityInfo> node = new VCIJTableNode<MachSecurityInfo>(obj);
|
node.setPropertyValue(getSpecialColumns()[0], obj.ipAddress);
|
node.setPropertyValue(getSpecialColumns()[1], obj.name);
|
|
if (mapSecurityEnum.containsKey(obj.secretGrade))
|
node.setPropertyValue(getSpecialColumns()[2], mapSecurityEnum.get(obj.secretGrade));
|
else
|
node.setPropertyValue(getSpecialColumns()[2], "");
|
node.setPropertyValue(getSpecialColumns()[3], obj.desc);
|
return node;
|
}
|
|
@Override
|
public String[] getSpecialColumns() {
|
return "IP地址, 机器名称, 密级, 描述".split(",");
|
}
|
|
@Override
|
public int getTotal() {
|
try {
|
total = (int)ClientSession.getFrameworkService().getMachSecurityTolalByCondition(condition.getName(),
|
condition.getIpAddress(), condition.getSecurity());
|
} catch (VCIError e) {
|
e.printStackTrace();
|
VCIOptionPane.showError(LogonApplication.frame, e);
|
}
|
return this.total;
|
}
|
|
}
|
|
public class SearchCondition {
|
private String name = "";
|
private String ipAddress = "";
|
private short security = 0;
|
|
public String getName() {
|
return name;
|
}
|
public void setName(String name) {
|
this.name = name;
|
}
|
public String getIpAddress() {
|
return ipAddress;
|
}
|
public void setIpAddress(String ipAddress) {
|
this.ipAddress = ipAddress;
|
}
|
public short getSecurity() {
|
return security;
|
}
|
public void setSecurity(short security) {
|
this.security = security;
|
}
|
|
}
|
MSDataProvider dataProvider = new MSDataProvider();
|
|
VCIJTablePanel<MachSecurityInfo> tablePanel = new VCIJTablePanel<MachSecurityInfo>(dataProvider);
|
|
private JPanel createQueryPanel() {
|
JPanel panel = new JPanel();
|
panel.setLayout(null);
|
panel.setPreferredSize(new Dimension(600,40));
|
|
int x = 20;
|
int y = 7;
|
int width = 50;
|
int height = 23;
|
|
ipLabel.setBounds(20, y, 50, height);
|
ipText.setBounds(70, y, 150, height);
|
nameLabel.setBounds(240, y, 50, height);
|
nameText.setBounds(290, y, 150, height);
|
securityLabel.setBounds(470, y, 50, height);
|
securityCombo.setBounds(520, y, 120, height);
|
|
searchButton.setBounds(660, y, width, height);
|
|
searchButton.addActionListener(new ActionListener(){
|
public void actionPerformed(ActionEvent e){
|
searchButton_actionPerformed();
|
}
|
});
|
|
panel.add(ipLabel);
|
panel.add(ipText);
|
panel.add(nameLabel);
|
panel.add(nameText);
|
panel.add(securityLabel);
|
panel.add(securityCombo);
|
panel.add(searchButton);
|
|
return panel;
|
}
|
|
private VCIJPanel createTablePanel() {
|
int startIndex = dataProvider.getDataColumnStartIndex();
|
LinkedHashMap<Integer, Integer> widthMaps = new LinkedHashMap<Integer, Integer>();
|
widthMaps.put(startIndex++, 150);
|
widthMaps.put(startIndex++, 250);
|
widthMaps.put(startIndex++, 100);
|
widthMaps.put(startIndex++, 400);
|
|
tablePanel.setColumnWidthMaps(widthMaps);
|
tablePanel.setCustomButtonFlowAlign(FlowLayout.CENTER);
|
tablePanel.setCustomButtons(selfCustomButtons);
|
tablePanel.setShowPaging(true);
|
tablePanel.setPageButtonFlowAlign(FlowLayout.CENTER);
|
tablePanel.setShowExport(true);
|
tablePanel.buildTablePanel();
|
tablePanel.refreshTableData();
|
return tablePanel;
|
}
|
|
private List<VCIJButton> selfCustomButtons = new ArrayList<VCIJButton>();
|
{
|
selfCustomButtons.add(addButton);
|
selfCustomButtons.add(editButton);
|
selfCustomButtons.add(deleteButton);
|
|
selfCustomButtons.add(importButton);
|
}
|
|
}
|