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<TableModel> 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;i<o.length;i++){
|
PLCommandParameter[] plcommandparameters = UITools.getService()
|
.getPLCommandParametersByCommandOId(o[i].plOId);
|
for(PLCommandParameter plCommandParameter : plcommandparameters){
|
UITools.getService().deletePLCommandParameter(plCommandParameter);
|
}
|
UITools.getService().deletePLTabButton(o[i]);
|
}
|
UITools.getService().deletePLPageDefination(plpagedefination);
|
}
|
UITools.getService().deletePLTabPage(plTabPage);
|
}
|
boolean flag = UITools.getService().deletePLUILayout(plpagelayoutdefination);
|
VCIOptionPane.showMessage(LogonApplication.frame, "删除成功");
|
initTreeNode();
|
} catch (VCIError e) {
|
e.printStackTrace();
|
VCIOptionPane.showMessage(LogonApplication.frame, "删除失败");
|
return;
|
}
|
}
|
}
|
});
|
btnPanel.add(relabutton);
|
}
|
btnPanel.add(clonebtn);
|
}
|
{
|
expBtn = new JButton("导出");
|
expBtn.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent arg0) {
|
TreePath path = btTree.getSelectionPath();
|
if(path==null){
|
VCIOptionPane.showMessage(LogonApplication.frame, "请选择一个类型!");
|
return;
|
}
|
ExpDialog dialog = new ExpDialog(btTree);
|
dialog.setVisible(true);
|
}
|
});
|
{
|
allExpBtn = new JButton("全部导出");
|
allExpBtn.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent arg0) {
|
|
BtmItem[] allBtItems = BtmProvider.getInstance().getAllBtmItems();
|
AllExpDialog allExp = new AllExpDialog(allBtItems);
|
}
|
});
|
btnPanel.add(allExpBtn);
|
}
|
btnPanel.add(expBtn);
|
}
|
{
|
impBtn = new JButton("导入");
|
impBtn.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent arg0) {
|
TreePath path = btTree.getSelectionPath();
|
String message = "请选择业务类型!";
|
// if(path ==null){
|
// VCIOptionPane.showMessage(LogonApplication.frame, message);
|
// return ;
|
// }
|
BtmItem obj = null;
|
if(path!=null){
|
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 ;
|
obj = (BtmItem) node.getObj();
|
}
|
}
|
ImportExcel imp = new ImportExcel(obj);
|
if(imp.impExcel()){
|
VCIOptionPane.showMessage(LogonApplication.frame, "导入成功");
|
initTreeNode();
|
}
|
}
|
});
|
btnPanel.add(impBtn);
|
}
|
delBtn.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;
|
if(check(plpagelayoutdefination)){
|
VCIOptionPane.showMessage(LogonApplication.frame, "包含子数据,不能删除!");
|
return;
|
}
|
try {
|
boolean flag = UITools.getService().deletePLUILayout(plpagelayoutdefination);
|
VCIOptionPane.showMessage(LogonApplication.frame, "删除成功");
|
initTreeNode();
|
} catch (VCIError e) {
|
e.printStackTrace();
|
VCIOptionPane.showMessage(LogonApplication.frame, "删除失败");
|
return;
|
}
|
}
|
if(uicontextobj instanceof PLTabPage){
|
PLTabPage pltabpage = (PLTabPage) uicontextobj;
|
if(check(pltabpage)){
|
VCIOptionPane.showMessage(LogonApplication.frame, "包含子数据,不能删除!");
|
return;
|
}
|
try {
|
boolean flag = UITools.getService().deletePLTabPage(pltabpage);
|
VCIOptionPane.showMessage(LogonApplication.frame, "删除成功");
|
initTreeNode();
|
} catch (VCIError e) {
|
e.printStackTrace();
|
VCIOptionPane.showMessage(LogonApplication.frame, "删除失败");
|
return;
|
}
|
}
|
if(uicontextobj instanceof PLPageDefination){
|
PLPageDefination plPageDefination = (PLPageDefination) uicontextobj;
|
if(checkBtnLength(plPageDefination)){
|
VCIOptionPane.showMessage(LogonApplication.frame,
|
"包含子数据,不能删除!");
|
return;
|
}
|
try {
|
boolean flag = UITools.getService().deletePLPageDefination(
|
plPageDefination);
|
VCIOptionPane.showMessage(LogonApplication.frame, "删除成功");
|
initTreeNode();
|
} catch (VCIError e) {
|
e.printStackTrace();
|
VCIOptionPane.showMessage(LogonApplication.frame, "删除失败");
|
return;
|
}
|
}
|
}
|
});
|
}
|
}
|
{
|
contextTreePanel = new JPanel();
|
BorderLayout tablePanelLayout = new BorderLayout();
|
contentPanel.add(contextTreePanel, BorderLayout.CENTER);
|
contextTreePanel.setLayout(tablePanelLayout);
|
{
|
dynamicPanel = new JPanel();
|
mainPanel.add(dynamicPanel, BorderLayout.CENTER);
|
dynamicPanel.setLayout(new BorderLayout(0, 0));
|
{
|
splitPane = new JSplitPane();
|
splitPane.setDividerSize(1);
|
splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
|
}
|
}
|
{
|
initContextTtreePanel();
|
}
|
}
|
}
|
}
|
}
|
} catch(Exception e) {
|
e.printStackTrace();
|
}
|
}
|
/**
|
* 构建树
|
*/
|
private void initContextTtreePanel() {
|
if(uifMangerTreePanel!=null){
|
contextTreePanel.remove(uifMangerTreePanel);
|
}
|
uifMangerTreePanel = new JPanel();
|
contextTreePanel.add(uifMangerTreePanel, BorderLayout.CENTER);
|
{
|
uifMangerTreePanel.setLayout(new BorderLayout());
|
{
|
scrollPane = new JScrollPane();
|
uifMangerTreePanel.add(scrollPane, BorderLayout.CENTER);
|
{
|
contextTreerootNode = new VCIBaseTreeNode(UI_CONTEXT,"root");
|
|
contextTreeModel = new VCIBaseTreeModel(contextTreerootNode);
|
contextTree = new VCIBaseTree(contextTreeModel, new ModuleTreeCellRenderer());
|
contextTree.setModel(contextTreeModel);
|
// treeManager = new CheckBoxTreeManager(contextTree);
|
scrollPane.setViewportView(contextTree);
|
|
contextTree.addTreeExpansionListener(new TreeExpansionListener() {
|
public void treeExpanded(TreeExpansionEvent event) {
|
TreePath path = event.getPath();
|
VCIBaseTreeNode selectNode = (VCIBaseTreeNode) path.getLastPathComponent();
|
Object object = selectNode.getObj();
|
TreePath bttreepath = btTree.getSelectionPath();
|
if(bttreepath==null){
|
VCIOptionPane.showMessage(LogonApplication.frame, "请选择类型!");
|
return;
|
}
|
VCIBaseTreeNode node = (VCIBaseTreeNode) bttreepath.getLastPathComponent();
|
BtmItem obj = (BtmItem) node.getObj();
|
btname = obj.name;
|
try {
|
if (!selectNode.isExpand()) {
|
selectNode.setExpand(true);
|
if(object instanceof PLUILayout){
|
PLUILayout plpagelayoutdefination= (PLUILayout)object;
|
if(plpagelayoutdefination.plIsShowNavigator==1){
|
btnTreeNode = new VCIBaseTreeNode("导航区", "1");
|
selectNode.add(btnTreeNode);
|
}
|
if(plpagelayoutdefination.plIsShowForm==1){
|
btnFormNode = new VCIBaseTreeNode("控制区", "2");
|
selectNode.add(btnFormNode);
|
}
|
if(plpagelayoutdefination.plIsShowTab==1){
|
btntabNode = new VCIBaseTreeNode("操作区", "3");
|
selectNode.add(btntabNode);
|
}
|
}
|
VCIBaseTreeNode parent = (VCIBaseTreeNode) selectNode.getParent();
|
Object parentObject = parent.getObj();
|
if(parentObject instanceof PLUILayout){
|
if(object.equals("1")){
|
PLUILayout plPageLayoutDefination = (PLUILayout) parentObject;
|
setPltabPageNode((short)1,btnTreeNode,
|
plPageLayoutDefination);
|
}
|
if(object.equals("2")){
|
PLUILayout plPageLayoutDefination = (PLUILayout) parentObject;
|
if(plPageLayoutDefination.plIsShowForm==1){
|
setPltabPageNode((short)2,btnFormNode,
|
plPageLayoutDefination);
|
}
|
}
|
if(object.equals("3")){
|
PLUILayout plPageLayoutDefination = (PLUILayout) parentObject;
|
if(plPageLayoutDefination.plIsShowTab==1){
|
setPltabPageNode((short)3,btntabNode,
|
plPageLayoutDefination);
|
}
|
}
|
}
|
if(object instanceof PLTabPage){
|
PLTabPage pltabpage = (PLTabPage)object;
|
PLPageDefination[] o = UITools.getService().getPLPageDefinationsByPageContextOId(
|
pltabpage.plOId);
|
for (int i = 0; i < o.length; i++) {
|
PLPageDefination plPageDefination = o[i];
|
if (plPageDefination.plType == 1) {
|
setplpagedefinationNode(
|
selectNode,
|
plPageDefination);
|
}
|
if (plPageDefination.plType == 2) {
|
setplpagedefinationNode(
|
selectNode,
|
plPageDefination);
|
}
|
if (plPageDefination.plType == 3) {
|
setplpagedefinationNode(
|
selectNode,
|
plPageDefination);
|
}
|
}
|
}
|
}
|
contextTreeModel.reload(selectNode);
|
}catch (VCIError e) {
|
e.printStackTrace();
|
}
|
}
|
|
@Override
|
public void treeCollapsed(TreeExpansionEvent arg0) {
|
|
}
|
});
|
|
contextTree.addMouseListener(new MouseAdapter() {
|
@Override
|
public void mouseClicked(MouseEvent arg0) {
|
clickContextTreeNode();
|
}
|
|
});
|
initTreeNode();
|
}
|
}
|
}
|
}
|
private void clickContextTreeNode() {
|
TreePath contextpath = contextTree.getSelectionPath();
|
if(contextpath==null)return;
|
VCIBaseTreeNode uicontextnode = (VCIBaseTreeNode) contextpath.getLastPathComponent();
|
Object uicontextobj = uicontextnode.getObj();
|
|
TreePath path = btTree.getSelectionPath();
|
if(path==null){
|
VCIOptionPane.showMessage(LogonApplication.frame, "请选择业务类型!");
|
return;
|
}
|
VCIBaseTreeNode node = (VCIBaseTreeNode) path.getLastPathComponent();
|
BtmItem obj = (BtmItem) node.getObj();
|
if(uicontextobj instanceof PLUILayout){
|
dynamicPanel.removeAll();
|
PLUILayout plpagelayoutdefination = (PLUILayout) uicontextobj;
|
UIContextDialog dialog = new UIContextDialog(obj,true,plpagelayoutdefination);
|
JPanel uicontextinit = dialog.init();
|
JScrollPane jsp = new JScrollPane();
|
jsp.setViewportView(uicontextinit);
|
uicontextinit.setBorder(new TitledBorder("ui定义设计页面"));
|
dynamicPanel.add(jsp,BorderLayout.CENTER);
|
relabutton.setVisible(true);
|
}
|
else if(uicontextobj instanceof PLTabPage){
|
VCIBaseTreeNode areaNode = (VCIBaseTreeNode) uicontextnode.getParent();
|
VCIBaseTreeNode plpagelayoutdefinationNode = (VCIBaseTreeNode) areaNode.getParent();
|
PLUILayout plpagelayoutdefination = (PLUILayout) plpagelayoutdefinationNode.getObj();
|
Object disType = areaNode.getObj();
|
dynamicPanel.removeAll();
|
PLTabPage pltabpage = (PLTabPage) uicontextobj;
|
TabDialog dialog = new TabDialog(plpagelayoutdefination, true,
|
pltabpage, Short.valueOf(disType.toString()));
|
JPanel pltabinit = dialog.init();
|
JScrollPane jsp = new JScrollPane();
|
jsp.setViewportView(pltabinit);
|
pltabinit.setBorder(new TitledBorder("页签设计页面"));
|
dynamicPanel.add(jsp,BorderLayout.CENTER);
|
relabutton.setVisible(false);
|
}
|
else if(uicontextobj instanceof PLPageDefination){
|
relabutton.setVisible(false);
|
String btmName = obj.name;
|
VCIBaseTreeNode tabPageNode = (VCIBaseTreeNode) uicontextnode.getParent();
|
PLTabPage pltabpage = (PLTabPage) tabPageNode.getObj();
|
VCIBaseTreeNode areaNode = (VCIBaseTreeNode) tabPageNode.getParent();
|
VCIBaseTreeNode plPageLayoutDefinationNode = (VCIBaseTreeNode) areaNode.getParent();
|
PLUILayout plpagelayoutdefination = (PLUILayout) plPageLayoutDefinationNode.getObj();
|
PLPageDefination plpagedefination = (PLPageDefination) uicontextobj;
|
dynamicPanel.removeAll();
|
UIDesinDialog dialog = null;
|
ButtonDialog buttondialog = null;
|
if(plpagelayoutdefination.plIsShowNavigator==1){
|
dialog = new UIDesinDialog(
|
plpagelayoutdefination, plpagedefination, btmName , (short)1,
|
pltabpage,true);
|
buttondialog = new ButtonDialog(plpagedefination,
|
plpagelayoutdefination, "navigator");
|
}
|
else if(plpagelayoutdefination.plIsShowForm==1){
|
dialog = new UIDesinDialog(
|
plpagelayoutdefination, plpagedefination, btmName, (short)2,
|
pltabpage,true);
|
buttondialog = new ButtonDialog(plpagedefination,
|
plpagelayoutdefination, "form");
|
}
|
else if(plpagelayoutdefination.plIsShowTab==1){
|
dialog = new UIDesinDialog(
|
plpagelayoutdefination, plpagedefination, btmName, (short)3,
|
pltabpage,true);
|
buttondialog = new ButtonDialog(plpagedefination,
|
plpagelayoutdefination, "tab");
|
}
|
JSplitPane jsd = new JSplitPane();
|
jsd.setDividerSize(1);
|
jsd.setOrientation(JSplitPane.VERTICAL_SPLIT);
|
jsd.setResizeWeight(0.5);
|
JScrollPane js = new JScrollPane();
|
JPanel uidesininit = dialog.init();
|
uidesininit.setBorder(new TitledBorder("UI设计页面"));
|
js.setViewportView(uidesininit);
|
jsd.setLeftComponent(js);
|
// dynamicPanel.add(js,BorderLayout.CENTER);
|
JScrollPane js1 = new JScrollPane();
|
JPanel buttoninit = buttondialog.init();
|
buttoninit.setBorder(new TitledBorder("按钮设计页面"));
|
js1.setViewportView(buttoninit);
|
jsd.setRightComponent(js1);
|
dynamicPanel.add(jsd,BorderLayout.CENTER);
|
}
|
// if(flush){
|
// initTreeNode();
|
// }
|
}
|
|
private void setplpagedefinationNode(
|
VCIBaseTreeNode selectNode,
|
PLPageDefination plPageDefination) {
|
VCIBaseTreeNode newnode = new VCIBaseTreeNode(plPageDefination.name, plPageDefination);
|
selectNode.add(newnode);
|
}
|
|
/**
|
* 初始化树节点
|
*/
|
public void initTreeNode(){
|
contextTreerootNode.removeAllChildren();
|
contextTree.updateUI();
|
|
TreePath path = btTree.getSelectionPath();
|
if(path==null){
|
return;
|
}
|
VCIBaseTreeNode node = (VCIBaseTreeNode) path.getLastPathComponent();
|
if(!(node.getObj() instanceof String)){
|
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].plCode+")", plpagelayoutdefinations[i]);
|
contextTreeModel.insertNodeInto(treeNode, contextTreerootNode,contextTreerootNode.getChildCount());
|
}
|
} catch (VCIError e) {
|
e.printStackTrace();
|
}
|
contextTree.setModel(contextTreeModel);
|
}
|
// treeManager = new CheckBoxTreeManager(contextTree);
|
// scrollPane.getViewport().removeAll();
|
// scrollPane.setViewportView(contextTree);
|
// scrollPane.repaint();
|
}
|
private void setPltabPageNode(short areatype,
|
VCIBaseTreeNode selectNode,
|
PLUILayout plpagelayoutdefination)
|
throws VCIError {
|
PLTabPage[] tabPagesByContextIdAndType = UITools.getService().getTabPagesByContextIdAndType(plpagelayoutdefination.plOId, areatype);
|
int length = tabPagesByContextIdAndType.length;
|
for(int i=0;i<length;i++){
|
PLTabPage plTabPage = tabPagesByContextIdAndType[i];
|
VCIBaseTreeNode newnode = new VCIBaseTreeNode(plTabPage.plName+"("+plTabPage.plCode+")", plTabPage);
|
selectNode.add(newnode);
|
}
|
}
|
|
private DefaultTreeModel createTreeModel() throws VCIError {
|
BtmItem[] allBtItems = BtmProvider.getInstance().getAllBtmItems();
|
VCIBaseTreeNode rootNode = new VCIBaseTreeNode("业务类型树","root");
|
VCIBaseTreeModel treeModel = new VCIBaseTreeModel(rootNode);
|
for(int i=0;i<allBtItems.length;i++){
|
|
VCIBaseTreeNode node = new VCIBaseTreeNode(allBtItems[i].name,allBtItems[i]);
|
treeModel.insertNodeInto(node, rootNode, rootNode.getChildCount());
|
}
|
return new DefaultTreeModel(rootNode);
|
}
|
|
private boolean check(PLUILayout plpagelayoutdefination){
|
boolean flag = false;
|
try {
|
PLPageDefination[] obj = UITools.getService().getPLPageDefinationsByPageContextOId(plpagelayoutdefination.plOId);
|
PLTabPage[] pltabPage = UITools.getService().getPLTabPagesByPageDefinationOId(plpagelayoutdefination.plOId);
|
if(obj.length>0||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;i<o.length;i++){
|
PLCommandParameter[] obj = UITools.getService()
|
.getPLCommandParametersByCommandOId(o[i].plOId);
|
if(obj.length>0){
|
flag = true;
|
break;
|
}
|
}
|
if (o.length > 0 ) {
|
flag = true;
|
}
|
} catch (VCIError e) {
|
e.printStackTrace();
|
}
|
return flag;
|
}
|
}
|