package com.vci.client.portal.NewUI; import java.awt.BorderLayout; import java.awt.FlowLayout; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import javax.swing.JButton; import javax.swing.JMenuItem; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JPopupMenu; import javax.swing.JScrollPane; import javax.swing.JSplitPane; import javax.swing.JTextField; import javax.swing.JTree; import javax.swing.border.TitledBorder; import javax.swing.event.TreeExpansionEvent; import javax.swing.event.TreeExpansionListener; import javax.swing.table.TableModel; import javax.swing.table.TableRowSorter; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultTreeModel; import javax.swing.tree.TreeNode; 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.common.VCIBasePanel; import com.vci.client.framework.rightConfig.modelConfig.ModuleTreeCellRenderer; import com.vci.client.framework.rightConfig.object.FunctionObject; import com.vci.client.omd.provider.BtmProvider; 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.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.client.ui.util.PostorderEnumeration; import com.vci.corba.common.VCIError; /** * This code was edited or generated using CloudGarden's Jigloo * SWT/Swing GUI Builder, which is free for non-commercial * use. If Jigloo is being used commercially (ie, by a corporation, * company or business for any purpose whatever) then you * should purchase a license for each developer using Jigloo. * Please visit www.cloudgarden.com for details. * Use of Jigloo implies acceptance of these licensing terms. * A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR * THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED * LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE. */ /** * UI管理 * @author liudi * * 2013-7-23 */ public class UIFManager extends VCIBasePanel { private static final String UI_CONTEXT = "UIContext树"; /** * */ private static final long serialVersionUID = 7438323020031787177L; private JSplitPane jSplitPane; private JSplitPane jrightSplitPane; private JPanel btnPanel; private JPanel uifMangerTreePanel; private TableRowSorter tableSorter; private VCIBaseTableModel uiFMangerTableModel; private JPanel contextTreePanel; private JButton delBtn; private JButton createBtn; private JPanel mainPanel; private JPanel contentPanel; private JTree btTree; JPopupMenu popupMenu = new JPopupMenu();//弹出式菜单 JMenuItem menuitem = new JMenuItem("刷新"); Object[][] strings = null; String[] columnHeaders = new String[] { "名称", "UI上下文"}; Class types[] = new Class[] { String.class, String.class }; private String btname = ""; private JScrollPane jscrollPanel ; private JButton clonebtn; private JButton expBtn; private JButton impBtn; private JScrollPane scrollPane; private JTree contextTree; private VCIBaseTreeModel contextTreeModel; private VCIBaseTreeNode contextTreerootNode; private CheckBoxTreeManager treeManager; private VCIBaseTreeNode btnTreeNode; private VCIBaseTreeNode btnFormNode; private VCIBaseTreeNode btntabNode; private JPanel dynamicPanel; private JSplitPane splitPane; private JButton reloadBtn; private JButton relabutton; private JButton allExpBtn; private JPanel left=new JPanel(),leftTopPanel=new JPanel(); private JButton sel; private JTextField textField; public UIFManager(FunctionObject funcObj){ super(funcObj); initGUI(); } private void initGUI() { try { { { this.setLayout(new BorderLayout()); jSplitPane = new JSplitPane(); jrightSplitPane = new JSplitPane(); this.add(jSplitPane); { //add by caill //添加定位框和定位按钮,并添加left和leftTopPanel容器 sel=new JButton("定位"); textField=new JTextField(20); //搜索框的设置 GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.weightx = 0.7; gbc.weighty = 0; gbc.fill = GridBagConstraints.HORIZONTAL; leftTopPanel.setLayout(new GridBagLayout()); leftTopPanel.add(textField,gbc); leftTopPanel.add(sel); left.setLayout(new BorderLayout()); left.add(leftTopPanel,BorderLayout.NORTH); popupMenu.add(menuitem); btTree = new JTree(); jscrollPanel = new JScrollPane(); jscrollPanel.setViewportView(btTree); left.add(jscrollPanel,BorderLayout.CENTER); jSplitPane.add(left, JSplitPane.LEFT); btTree.setModel(createTreeModel()); //为定位按钮添加点击事件 sel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { //e.getSource(); String test = textField.getText().trim(); DefaultTreeModel model = (DefaultTreeModel)btTree.getModel(); model.reload(); TreeNode root = (TreeNode) model.getRoot(); PostorderEnumeration enumeration = new PostorderEnumeration( root); while (enumeration.hasMoreElements()) { DefaultMutableTreeNode element = (DefaultMutableTreeNode) enumeration .nextElement(); if (element.getUserObject() instanceof String) { String wrapper = (String) element .getUserObject(); if (wrapper != null && wrapper.equals(test)) { TreeNode[] path = element.getPath(); TreePath treePath = new TreePath(path); btTree.setSelectionPath(treePath); return; } ; } } if (test.equals("")) { JOptionPane.showMessageDialog( com.vci.client.LogonApplication.frame, "请输入业务类型", "提示", JOptionPane.INFORMATION_MESSAGE); } else { JOptionPane.showMessageDialog( com.vci.client.LogonApplication.frame, "{ " + test + " }业务类型不存在", "提示", JOptionPane.INFORMATION_MESSAGE); } } }); textField.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JTextField text = (JTextField) e.getSource(); String test = text.getText().trim(); DefaultTreeModel model = (DefaultTreeModel)btTree.getModel(); model.reload(); TreeNode root = (TreeNode) model.getRoot(); PostorderEnumeration enumeration = new PostorderEnumeration( root); while (enumeration.hasMoreElements()) { DefaultMutableTreeNode element = (DefaultMutableTreeNode) enumeration .nextElement(); if (element.getUserObject() instanceof String) { String wrapper = (String) element .getUserObject(); if (wrapper != null && wrapper.equals(test)) { TreeNode[] path = element.getPath(); TreePath treePath = new TreePath(path); btTree.setSelectionPath(treePath); return; } ; } } if (test.equals("")) { JOptionPane.showMessageDialog( com.vci.client.LogonApplication.frame, "请输入业务类型", "提示", JOptionPane.INFORMATION_MESSAGE); } else { JOptionPane.showMessageDialog( com.vci.client.LogonApplication.frame, "{ " + test + " }业务类型不存在", "提示", JOptionPane.INFORMATION_MESSAGE); } } }); //add by caill end btTree.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { initContextTtreePanel(); } @Override public void mouseReleased(MouseEvent e) { super.mouseReleased(e); if(e.isPopupTrigger()){ popupMenu.show(btTree, e.getX(), e.getY()); } } }); menuitem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { try { btTree.setModel(createTreeModel()); } catch (VCIError e) { e.printStackTrace(); } } }); } { mainPanel = new JPanel(); mainPanel.setLayout(new BorderLayout()); contentPanel = new JPanel(); BorderLayout contentPanelLayout = new BorderLayout(); contentPanel.setLayout(contentPanelLayout); mainPanel.add(contentPanel,BorderLayout.WEST); jSplitPane.add(mainPanel, JSplitPane.RIGHT); { btnPanel = new JPanel(); FlowLayout jPanel1Layout = new FlowLayout(); contentPanel.add(btnPanel, BorderLayout.NORTH); btnPanel.setLayout(jPanel1Layout); { reloadBtn = new JButton("刷新"); reloadBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { initTreeNode(); } }); btnPanel.add(reloadBtn); } { createBtn = new JButton(); btnPanel.add(createBtn); createBtn.setText("创建"); createBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { viewInfo(); } private void viewInfo() { TreePath path = btTree.getSelectionPath(); String message = "请选择业务类型!"; if(path ==null){ VCIOptionPane.showMessage(LogonApplication.frame, message); return ; } VCIBaseTreeNode node = (VCIBaseTreeNode) path.getLastPathComponent(); if(node.getObj()==null){ VCIOptionPane.showMessage(LogonApplication.frame, message); return ; } if(node.getObj() instanceof String){ VCIOptionPane.showMessage(LogonApplication.frame, message); return ; } BtmItem obj = (BtmItem) node.getObj(); TreePath contextpath = contextTree.getSelectionPath(); if(contextpath==null){ VCIOptionPane.showMessage(LogonApplication.frame, "请选择根节点!"); return ; } VCIBaseTreeNode uicontextnode = (VCIBaseTreeNode) contextpath.getLastPathComponent(); Object uicontextobj = uicontextnode.getObj(); if("root".equals(uicontextobj)){ UIContextDialog dialog = new UIContextDialog(obj,false,null); dialog.setLocationRelativeTo(null); dialog.setVisible(true); if(dialog.isCloseFlag()){ initTreeNode(); } }else{ if("1".equals(uicontextobj)||"2".equals(uicontextobj)||"3".equals(uicontextobj)){ VCIBaseTreeNode parent = (VCIBaseTreeNode) uicontextnode.getParent(); Object parentObject = parent.getObj(); if(parentObject instanceof PLUILayout){ PLUILayout plpagelayoutdefination = (PLUILayout) parentObject; TabDialog dialog = new TabDialog(plpagelayoutdefination, false, null,Short.valueOf(uicontextobj.toString())); dialog.setLocationRelativeTo(null); dialog.setVisible(true); if(dialog.isCloseFlag()){ initTreeNode(); } } } else{ if(uicontextobj instanceof PLTabPage){ VCIBaseTreeNode areaNode = (VCIBaseTreeNode) uicontextnode.getParent(); VCIBaseTreeNode plPageLayoutDefinationNode = (VCIBaseTreeNode) areaNode.getParent(); Object parentObject = plPageLayoutDefinationNode.getObj(); PLTabPage pltabpage = (PLTabPage) uicontextobj; if(parentObject instanceof PLUILayout){ PLUILayout plpagelayoutdefination = (PLUILayout) parentObject; UIDesinDialog dialog = null; String btmName = obj.name; if(plpagelayoutdefination.plIsShowNavigator==1){ dialog = new UIDesinDialog( plpagelayoutdefination, null, btmName , (short)1, pltabpage); } else if(plpagelayoutdefination.plIsShowForm==1){ dialog = new UIDesinDialog( plpagelayoutdefination, null, btmName, (short)2, pltabpage); } else if(plpagelayoutdefination.plIsShowTab==1){ dialog = new UIDesinDialog( plpagelayoutdefination, null, btmName, (short)3, pltabpage); } dialog.setLocationRelativeTo(null); dialog.setVisible(true); if(dialog.isCloseFlag()){ initTreeNode(); } } }else{ VCIOptionPane.showMessage(LogonApplication.frame, "请选择上级节点创建!"); return; } } } } }); } { delBtn = new JButton(); btnPanel.add(delBtn); delBtn.setText("删除"); { clonebtn = new JButton("克隆"); clonebtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { CloneDialog dialog = new CloneDialog(btTree); dialog.setVisible(true); if(dialog.isCloasflag()){ initTreeNode(); } } }); { relabutton = new JButton("级联删除"); relabutton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { TreePath contextpath = contextTree.getSelectionPath(); if(contextpath==null){ VCIOptionPane.showMessage(LogonApplication.frame, "请选择节点!"); return ; } if (VCIOptionPane.showQuestion(LogonApplication.frame, "确定要删除记录吗?") != 0) { return; } VCIBaseTreeNode uicontextnode = (VCIBaseTreeNode) contextpath.getLastPathComponent(); Object uicontextobj = uicontextnode.getObj(); if(uicontextobj instanceof String){ VCIOptionPane.showMessage(LogonApplication.frame, "不能删除此节点!"); return ; } if(uicontextobj instanceof PLUILayout){ PLUILayout plpagelayoutdefination = (PLUILayout) uicontextobj; try { PLTabPage[] pltabPages = UITools.getService().getPLTabPagesByPageDefinationOId(plpagelayoutdefination.plOId); for(PLTabPage plTabPage : pltabPages){ PLPageDefination[] obj = UITools.getService().getPLPageDefinationsByPageContextOId(plTabPage.plOId); for(PLPageDefination plpagedefination : obj){ PLTabButton[] o = UITools.getService().getPLTabButtonsByTableOId(plpagedefination.plOId); for(int i=0;i0||pltabPage.length>0){ flag = true; } } catch (VCIError e) { e.printStackTrace(); } return flag; } private boolean check(PLTabPage pltabpage) { boolean flag = false; try { PLPageDefination[] obj = UITools.getService() .getPLPageDefinationsByPageContextOId( pltabpage.plOId); if (obj.length > 0 ) { flag = true; } } catch (VCIError e) { e.printStackTrace(); } return flag; } private boolean checkBtnLength(PLPageDefination plPageDefination) { boolean flag = false; try { PLTabButton[] o = UITools.getService().getPLTabButtonsByTableOId(plPageDefination.plOId); for(int i=0;i0){ flag = true; break; } } if (o.length > 0 ) { flag = true; } } catch (VCIError e) { e.printStackTrace(); } return flag; } }