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.JPanel; import javax.swing.JScrollPane; import javax.swing.JTree; import javax.swing.border.EmptyBorder; import javax.swing.tree.TreePath; import com.vci.corba.omd.btm.BtmItem; 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.util.ArrayList; import java.util.Date; import java.util.List; import javax.swing.JLabel; import javax.swing.JTextField; import java.awt.GridBagLayout; import java.awt.GridBagConstraints; import java.awt.Insets; public class CloneDialog 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 nodeList = new ArrayList(); private boolean cloasflag = false; private Object clonedestObject; private JTextField textField; public boolean isCloasflag() { return cloasflag; } public void setCloasflag(boolean cloasflag) { this.cloasflag = cloasflag; } /** * Create the dialog. */ public CloneDialog(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 panel = new JPanel(); contentPanel.add(panel, BorderLayout.NORTH); GridBagLayout gbl_panel = new GridBagLayout(); gbl_panel.columnWidths = new int[]{48, 243, 81, 0}; gbl_panel.rowHeights = new int[]{23, 0}; gbl_panel.columnWeights = new double[]{0.0, 0.0, 0.0, Double.MIN_VALUE}; gbl_panel.rowWeights = new double[]{0.0, Double.MIN_VALUE}; panel.setLayout(gbl_panel); { JLabel label = new JLabel("克隆目标"); GridBagConstraints gbc_label = new GridBagConstraints(); gbc_label.insets = new Insets(0, 0, 0, 5); gbc_label.gridx = 0; gbc_label.gridy = 0; panel.add(label, gbc_label); } { textField = new JTextField(); textField.setFocusable(false); textField.setEditable(false); GridBagConstraints gbc_textField = new GridBagConstraints(); gbc_textField.fill = GridBagConstraints.HORIZONTAL; gbc_textField.insets = new Insets(0, 0, 0, 5); gbc_textField.gridx = 1; gbc_textField.gridy = 0; panel.add(textField, gbc_textField); textField.setColumns(10); } { JButton clonedestbutton = new JButton("克隆目标"); clonedestbutton.setToolTipText("*如果选择克隆目标,则克隆到选择的类型下,如果没有选择克隆目标,则克隆到当前类型下"); GridBagConstraints gbc_clonedestbutton = new GridBagConstraints(); gbc_clonedestbutton.anchor = GridBagConstraints.NORTH; gbc_clonedestbutton.gridx = 2; gbc_clonedestbutton.gridy = 0; panel.add(clonedestbutton, gbc_clonedestbutton); clonedestbutton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { UICloneDestDialog clonedestdia = new UICloneDestDialog(); clonedestdia.setVisible(true); clonedestObject = clonedestdia.getTreeObject(); if(clonedestObject instanceof BtmItem){ textField.setText(((BtmItem)clonedestObject).name); } } }); } } { 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) { 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); } } }else{ VCIOptionPane.showMessage(LogonApplication.frame, "请选择要克隆的节点!"); return; } cloasflag = true; dispose(); } }); buttonPane.add(okButton); getRootPane().setDefaultButton(okButton); } { JButton cancelButton = new JButton("关闭"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { dispose(); } }); buttonPane.add(cancelButton); } } } 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