package com.vci.client.portal.NewUI;
|
|
import java.awt.BorderLayout;
|
import java.awt.FlowLayout;
|
|
import javax.swing.JButton;
|
import javax.swing.JDialog;
|
import javax.swing.JFileChooser;
|
import javax.swing.JPanel;
|
import javax.swing.JScrollPane;
|
import javax.swing.JTree;
|
import javax.swing.border.EmptyBorder;
|
import javax.swing.filechooser.FileFilter;
|
import javax.swing.tree.TreePath;
|
|
import org.apache.poi.hssf.usermodel.HSSFCell;
|
import org.apache.poi.hssf.usermodel.HSSFRow;
|
import org.apache.poi.hssf.usermodel.HSSFSheet;
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
import com.vci.corba.omd.btm.BtmItem;
|
import com.vci.corba.portal.data.PLAction;
|
import com.vci.corba.portal.data.PLCommandParameter;
|
import com.vci.corba.portal.data.PLPageDefination;
|
import com.vci.corba.portal.data.PLUILayout;
|
import com.vci.corba.portal.data.PLTabButton;
|
import com.vci.corba.portal.data.PLTabPage;
|
import com.vci.client.LogonApplication;
|
import com.vci.client.framework.delegate.FunctionClientDelegate;
|
import com.vci.client.framework.delegate.RoleRightClientDelegate;
|
import com.vci.client.framework.rightConfig.modelConfig.ModuleTreeCellRenderer;
|
import com.vci.client.framework.rightConfig.object.FuncOperationObject;
|
import com.vci.client.framework.rightConfig.object.FunctionObject;
|
import com.vci.client.framework.rightdistribution.object.RoleRightObject;
|
import com.vci.client.portal.utility.UITools;
|
import com.vci.client.ui.exception.VCIException;
|
import com.vci.client.ui.locale.LocaleDisplay;
|
import com.vci.client.ui.swing.VCIOptionPane;
|
import com.vci.client.ui.tree.CheckBoxTreeManager;
|
import com.vci.client.ui.tree.VCIBaseTree;
|
import com.vci.client.ui.tree.VCIBaseTreeModel;
|
import com.vci.client.ui.tree.VCIBaseTreeNode;
|
import com.vci.common.utility.ObjectUtility;
|
import com.vci.corba.common.VCIError;
|
|
import java.awt.event.ActionListener;
|
import java.awt.event.ActionEvent;
|
import java.io.File;
|
import java.io.FileNotFoundException;
|
import java.io.FileOutputStream;
|
import java.io.IOException;
|
import java.util.ArrayList;
|
import java.util.Date;
|
import java.util.List;
|
|
public class ExpDialog extends JDialog {
|
|
/**
|
*
|
*/
|
private static final long serialVersionUID = 1L;
|
|
private final JPanel contentPanel = new JPanel();
|
|
private VCIBaseTree tree;
|
private VCIBaseTreeModel treeModel;
|
private CheckBoxTreeManager treeManager;
|
private VCIBaseTreeNode rootNode;
|
private JScrollPane scrollPane ;
|
|
private JTree btTree;
|
|
private String btname;
|
|
private String plpageLayoutDefinationId= "";
|
List<String> nodeList = new ArrayList<String>();
|
|
HSSFWorkbook workbook;
|
HSSFSheet sheet_pagelayoutdefination;
|
HSSFSheet sheet_pagedefination;
|
HSSFSheet sheet_tabpage;
|
HSSFSheet sheet_tabbutton;
|
HSSFSheet sheet_commondParam;
|
HSSFSheet sheet_action;
|
|
int pageLayoutDefinationindex = 0;
|
int tabpageIndex = 0;
|
int pagedefinationIndex = 0;
|
int tabbuttonIndex = 0;
|
int commondParamIndex = 0;
|
int actionIndex = 0;
|
|
/**
|
* 记录action信息
|
*/
|
List<String> actionList = new ArrayList<String>();
|
private String xfileName = "";
|
/**
|
* Create the dialog.
|
*/
|
public ExpDialog(JTree btTree) {
|
super(LogonApplication.frame,true);
|
this.btTree = btTree;
|
init();
|
initTreeNode();
|
this.setLocationRelativeTo(null);
|
}
|
|
private void init() {
|
setBounds(100, 100, 450, 300);
|
getContentPane().setLayout(new BorderLayout());
|
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
|
getContentPane().add(contentPanel, BorderLayout.CENTER);
|
contentPanel.setLayout(new BorderLayout(0, 0));
|
{
|
scrollPane = new JScrollPane();
|
contentPanel.add(scrollPane, BorderLayout.CENTER);
|
}
|
{
|
JPanel buttonPane = new JPanel();
|
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
|
getContentPane().add(buttonPane, BorderLayout.SOUTH);
|
{
|
JButton okButton = new JButton("确定");
|
okButton.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent arg0) {
|
TreePath[] treePath = treeManager.getSelectionModel().getSelectionPaths();
|
if(treePath == null){
|
VCIOptionPane.showMessage(LogonApplication.frame, "请选择要导出的节点!");
|
return;
|
}
|
openFileChoser();
|
if (treePath != null) {
|
pageLayoutDefinationindex = 0;
|
tabpageIndex = 0;
|
pagedefinationIndex = 0;
|
tabbuttonIndex = 0;
|
commondParamIndex = 0;
|
for(int i = 0;i < treePath.length;i++){
|
VCIBaseTreeNode node = (VCIBaseTreeNode)treePath[i].getLastPathComponent();
|
Object obj = node.getObj();
|
if(obj instanceof String){//如果是root节点,则保存所有模块
|
getNextNode(node,false);//向下获取所有几点
|
}else if(obj instanceof PLUILayout){
|
getNextNode(node,false);//向下处理(包含当前节点)
|
}else if (obj instanceof PLTabPage){
|
getNextNode(node,true);
|
savePlpageLayoutDefinationRelation(obj);
|
}
|
}
|
}
|
if(writeFile()){
|
VCIOptionPane.showMessage(LogonApplication.frame, "导出成功");
|
dispose();
|
}
|
}
|
});
|
buttonPane.add(okButton);
|
getRootPane().setDefaultButton(okButton);
|
}
|
{
|
JButton cancelButton = new JButton("关闭");
|
cancelButton.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent arg0) {
|
dispose();
|
}
|
});
|
buttonPane.add(cancelButton);
|
}
|
}
|
workbook = new HSSFWorkbook();
|
sheet_pagelayoutdefination = workbook.createSheet();
|
workbook.setSheetName(0, "PlpageLayoutDefnation");
|
|
sheet_tabpage = workbook.createSheet();
|
workbook.setSheetName(1, "Pltabpage");
|
|
sheet_pagedefination = workbook.createSheet();
|
workbook.setSheetName(2, "Plpagedefination");
|
|
sheet_tabbutton = workbook.createSheet();
|
workbook.setSheetName(3, "Pltabbutton");
|
|
sheet_commondParam = workbook.createSheet();
|
workbook.setSheetName(4, "PlcommondParam");
|
|
sheet_action = workbook.createSheet();
|
workbook.setSheetName(5, "PlAction");
|
}
|
|
|
public void initTreeNode(){
|
rootNode = new VCIBaseTreeNode("区域", "root");
|
treeModel = new VCIBaseTreeModel(rootNode);
|
tree = new VCIBaseTree(treeModel, new ModuleTreeCellRenderer());
|
|
TreePath path = btTree.getSelectionPath();
|
if(path==null){
|
VCIOptionPane.showMessage(LogonApplication.frame, "请选择一个类型!");
|
return;
|
}
|
VCIBaseTreeNode node = (VCIBaseTreeNode) path.getLastPathComponent();
|
BtmItem obj = (BtmItem) node.getObj();
|
btname = obj.name;
|
try {
|
PLUILayout[] plpagelayoutdefinations = UITools.getService().getPLUILayoutsByRelatedType(btname);
|
for(int i=0;i<plpagelayoutdefinations.length;i++){
|
VCIBaseTreeNode treeNode = new VCIBaseTreeNode(plpagelayoutdefinations[i].plName, plpagelayoutdefinations[i]);
|
treeModel.insertNodeInto(treeNode, rootNode,rootNode.getChildCount());
|
insertNode(plpagelayoutdefinations, i, treeNode,(short)1);
|
insertNode(plpagelayoutdefinations, i, treeNode,(short)2);
|
insertNode(plpagelayoutdefinations, i, treeNode,(short)3);
|
}
|
} catch (VCIError e) {
|
e.printStackTrace();
|
}
|
tree.setModel(treeModel);
|
treeManager = new CheckBoxTreeManager(tree);
|
scrollPane.getViewport().removeAll();
|
scrollPane.setViewportView(tree);
|
scrollPane.repaint();
|
}
|
|
private PLTabPage[] insertNode(
|
PLUILayout[] plpagelayoutdefinations, int i,
|
VCIBaseTreeNode treeNode,short disType) throws VCIError {
|
PLTabPage[] o = UITools.getService().getTabPagesByContextIdAndType(plpagelayoutdefinations[i].plOId, disType);
|
for(int j=0;j<o.length;j++){
|
VCIBaseTreeNode areaNode = new VCIBaseTreeNode(o[j].plName, o[j]);
|
treeModel.insertNodeInto(areaNode, treeNode,treeNode.getChildCount());
|
}
|
return o;
|
}
|
|
private void getNextNode(VCIBaseTreeNode node,boolean isUp){
|
if(isUp){//向上获取,存储每个上级模块的权限值
|
VCIBaseTreeNode parentNode = (VCIBaseTreeNode)node.getParent();
|
while(!"root".equals(parentNode.getObj())){
|
Object obj = parentNode.getObj();
|
Object userObject = parentNode.getUserObject();
|
if(!nodeList.contains((String)userObject)){
|
nodeList.add((String)userObject);
|
savePlpageLayoutDefnation(obj);
|
}
|
parentNode = (VCIBaseTreeNode)parentNode.getParent();
|
}
|
}else{//向下获取,无需判断是否选中,但需要判断其子级是否是操作
|
//先存储当前节点
|
Object obj = node.getObj();
|
if(obj instanceof PLUILayout){
|
savePlpageLayoutDefnation(obj);
|
}else if(obj instanceof PLTabPage){
|
savePlpageLayoutDefinationRelation(obj);
|
}
|
for(int i = 0;i < node.getChildCount();i++){
|
//对每个子向下递归遍历
|
getNextNode((VCIBaseTreeNode)node.getChildAt(i),false);
|
}
|
}
|
}
|
|
private void savePlpageLayoutDefnation(Object object) {
|
PLUILayout obj = (PLUILayout)object;
|
plpageLayoutDefinationId = obj.plOId;
|
// try {
|
HSSFRow row = sheet_pagelayoutdefination.createRow(pageLayoutDefinationindex++);
|
HSSFCell cell = row.createCell(0);
|
cell.setCellValue(obj.plName);
|
cell = row.createCell(1);
|
cell.setCellValue(obj.plCode);
|
cell = row.createCell(2);
|
cell.setCellValue(obj.plOId);
|
cell = row.createCell(3);
|
cell.setCellValue(btname);
|
cell = row.createCell(4);
|
cell.setCellValue(obj.plRelatedType);
|
cell = row.createCell(5);
|
cell.setCellValue(obj.plIsShowNavigator);
|
cell = row.createCell(6);
|
cell.setCellValue(obj.plIsShowTab);
|
cell = row.createCell(7);
|
cell.setCellValue(obj.plIsShowForm);
|
// Tool.getService().savePLUILayout(obj);
|
// } catch (VCIError e) {
|
// e.printStackTrace();
|
// }
|
}
|
|
private void savePlpageLayoutDefinationRelation(Object obj) {
|
PLTabPage pt = (PLTabPage)obj;
|
pt.plContextOId = plpageLayoutDefinationId;
|
HSSFRow row = sheet_tabpage.createRow(tabpageIndex++);
|
HSSFCell cell = row.createCell(0);
|
cell.setCellValue(pt.plName);
|
cell = row.createCell(1);
|
cell.setCellValue(pt.plCode);
|
cell = row.createCell(2);
|
cell.setCellValue(pt.plSeq);
|
cell = row.createCell(3);
|
cell.setCellValue(pt.plContextOId);
|
cell = row.createCell(4);
|
cell.setCellValue(pt.plDesc);
|
cell = row.createCell(5);
|
cell.setCellValue(pt.plIsOpen);
|
cell = row.createCell(6);
|
cell.setCellValue(pt.plAreaType);
|
cell = row.createCell(7);
|
cell.setCellValue(pt.plOpenExpression);
|
cell = row.createCell(8);
|
cell.setCellValue(pt.plLicensOrs);
|
cell = row.createCell(9);
|
cell.setCellValue(pt.plLabel);
|
cell = row.createCell(10);
|
cell.setCellValue(pt.plOId);
|
try {
|
|
PLPageDefination[] pLPageDefinations = UITools.getService().getPLPageDefinationsByPageContextOId(
|
pt.plOId);
|
|
for(int j=0;j<pLPageDefinations.length;j++){
|
PLPageDefination plPageDefination = pLPageDefinations[j];
|
|
plPageDefination.plTabPageOId = pt.plOId;
|
HSSFRow row1 = sheet_pagedefination.createRow(j+pagedefinationIndex);
|
HSSFCell cell1 = row1.createCell(0);
|
cell1.setCellValue(plPageDefination.name);
|
cell1 = row1.createCell(1);
|
cell1.setCellValue(plPageDefination.plDefination);
|
cell1 = row1.createCell(2);
|
cell1.setCellValue(plPageDefination.seq);
|
cell1 = row1.createCell(3);
|
cell1.setCellValue(plPageDefination.plTabPageOId);
|
cell1 = row1.createCell(4);
|
cell1.setCellValue(plPageDefination.desc);
|
cell1 = row1.createCell(5);
|
cell1.setCellValue(plPageDefination.plType);
|
cell1 = row1.createCell(6);
|
cell1.setCellValue(plPageDefination.plOId);
|
|
PLTabButton[] pLTabButtons = UITools.getService().getPLTabButtonsByTableOId(plPageDefination.plOId);
|
for(int b=0;b<pLTabButtons.length;b++){
|
PLTabButton plTabButton = pLTabButtons[b];
|
plTabButton.plTableOId = plPageDefination.plOId;
|
HSSFRow row2 = sheet_tabbutton.createRow(b+tabbuttonIndex);
|
HSSFCell cell2 = row2.createCell(0);
|
cell2.setCellValue(plTabButton.plLabel);
|
cell2 = row2.createCell(1);
|
cell2.setCellValue(plTabButton.plAreaType);
|
cell2 = row2.createCell(2);
|
cell2.setCellValue(plTabButton.plTableOId);
|
cell2 = row2.createCell(3);
|
cell2.setCellValue(plTabButton.plSeq);
|
cell2 = row2.createCell(4);
|
PLAction plAction = UITools.getService().getPLActionById(plTabButton.plActionOId);
|
cell2.setCellValue(plAction.plCode);
|
//导出action内容--start
|
if(!actionList.contains(plAction.plCode)){
|
HSSFRow actionHSSFRow = sheet_action.createRow(actionIndex);
|
actionList.add(plAction.plCode);
|
HSSFCell actionHSSFcell = actionHSSFRow.createCell(0);
|
actionHSSFcell.setCellValue(plAction.plOId);
|
actionHSSFcell = actionHSSFRow.createCell(1);
|
actionHSSFcell.setCellValue(plAction.plName);
|
actionHSSFcell = actionHSSFRow.createCell(2);
|
actionHSSFcell.setCellValue(plAction.plCode);
|
actionHSSFcell = actionHSSFRow.createCell(3);
|
actionHSSFcell.setCellValue(plAction.plActionCls);
|
actionHSSFcell = actionHSSFRow.createCell(4);
|
actionHSSFcell.setCellValue(plAction.plBSUrl);
|
actionHSSFcell = actionHSSFRow.createCell(5);
|
actionHSSFcell.setCellValue(plAction.plCSClass);
|
actionHSSFcell = actionHSSFRow.createCell(6);
|
actionHSSFcell.setCellValue(plAction.plTypeType);
|
actionHSSFcell = actionHSSFRow.createCell(7);
|
actionHSSFcell.setCellValue(plAction.plLicensOrs);
|
actionHSSFcell = actionHSSFRow.createCell(8);
|
actionHSSFcell.setCellValue(plAction.plDesc);
|
actionIndex++;
|
}
|
//导出action内容--end
|
cell2 = row2.createCell(5);
|
cell2.setCellValue(plTabButton.plAreaType);
|
cell2 = row2.createCell(6);
|
cell2.setCellValue(plTabButton.plDesc);
|
cell2 = row2.createCell(7);
|
cell2.setCellValue(plTabButton.plOId);
|
cell2 = row2.createCell(8);
|
cell2.setCellValue(plTabButton.plParentOid);
|
cell2 = row2.createCell(9);
|
cell2.setCellValue(plTabButton.displayMode);
|
cell2 = row2.createCell(10);
|
cell2.setCellValue(plTabButton.iconPath);
|
cell2 = row2.createCell(11);
|
cell2.setCellValue(plTabButton.authorization);
|
|
PLCommandParameter[] pLCommandParameters = UITools.getService().getPLCommandParametersByCommandOId(plTabButton.plOId);
|
for(int c=0;c<pLCommandParameters.length;c++){
|
PLCommandParameter plCommandParameter = pLCommandParameters[c];
|
plCommandParameter.plCommandOId = plTabButton.plOId;
|
HSSFRow row3 = sheet_commondParam.createRow(c+commondParamIndex);
|
HSSFCell cell3 = row3.createCell(0);
|
cell3.setCellValue(plCommandParameter.plCommandOId);
|
cell3 = row3.createCell(1);
|
cell3.setCellValue(plCommandParameter.plKey);
|
cell3 = row3.createCell(2);
|
cell3.setCellValue(plCommandParameter.plValue);
|
cell3 = row3.createCell(3);
|
cell3.setCellValue(plCommandParameter.plOId);
|
}
|
if(pLCommandParameters.length>0){
|
commondParamIndex += pLCommandParameters.length;
|
}
|
}
|
tabbuttonIndex += pLTabButtons.length;
|
}
|
pagedefinationIndex += pLPageDefinations.length;
|
} catch (VCIError e) {
|
e.printStackTrace();
|
}
|
}
|
|
private void openFileChoser(){
|
JFileChooser jf = new JFileChooser();
|
jf.setDialogTitle("打开");
|
jf.removeChoosableFileFilter(jf.getFileFilter());
|
jf.setFileFilter(new FileFilter() {
|
|
@Override
|
public String getDescription() {
|
return "xls";
|
}
|
|
@Override
|
public boolean accept(File f) {
|
if(f.isDirectory()||f.getName().endsWith(".xls")){
|
return true;
|
}else{
|
return false;
|
}
|
}
|
});
|
int showOpenDialog = jf.showOpenDialog(LogonApplication.frame);
|
if (showOpenDialog == JFileChooser.APPROVE_OPTION) {
|
File file = jf.getSelectedFile();
|
xfileName = file.getAbsolutePath();
|
if(!xfileName.endsWith(".xls")){
|
xfileName = xfileName+".xls";
|
}
|
}
|
}
|
|
private boolean writeFile(){
|
try {
|
FileOutputStream fout = new FileOutputStream(xfileName);
|
workbook.write(fout);
|
fout.flush();
|
fout.close();
|
System.out.println("文件生成.....");
|
return true;
|
} catch (FileNotFoundException e) {
|
e.printStackTrace();
|
return false;
|
} catch (IOException e) {
|
e.printStackTrace();
|
return false;
|
}
|
}
|
}
|