package com.vci.client.portal.platformPortal;
|
|
import java.awt.BorderLayout;
|
import java.awt.FlowLayout;
|
import java.awt.GridLayout;
|
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionListener;
|
|
import javax.swing.ButtonGroup;
|
import javax.swing.JButton;
|
import javax.swing.JDialog;
|
import javax.swing.JPanel;
|
import javax.swing.JRadioButton;
|
import javax.swing.JScrollPane;
|
import javax.swing.JTree;
|
import javax.swing.tree.DefaultMutableTreeNode;
|
|
import com.vci.client.LogonApplication;
|
import com.vci.client.omd.btm.ui.BtmTree;
|
import com.vci.client.omd.linktype.LinkTypeTree;
|
import com.vci.client.ui.swing.VCIOptionPane;
|
import com.vci.client.ui.tree.VCIBaseTreeNode;
|
|
public class UICloneDestDialog extends JDialog {
|
/**
|
* 树对象
|
*/
|
private Object treeObject;
|
private JTree btmTree ;
|
private JTree linkTypeTree ;
|
private ButtonGroup bg ;
|
private JRadioButton btmTerrBtn;
|
private JRadioButton linktypeTreeBtn;
|
private JPanel treePanel;
|
private JScrollPane treescrollPane;
|
private int typeFlag;
|
public Object getTreeObject() {
|
return treeObject;
|
}
|
|
public void setTreeObject(Object treeObject) {
|
this.treeObject = treeObject;
|
}
|
|
/**
|
* Launch the application.
|
*/
|
public static void main(String[] args) {
|
try {
|
UICloneDestDialog dialog = new UICloneDestDialog();
|
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
dialog.setVisible(true);
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
}
|
|
/**
|
* Create the dialog.
|
*/
|
public UICloneDestDialog() {
|
super(LogonApplication.frame,true);
|
init();
|
|
actionListener();
|
|
this.setLocationRelativeTo(null);
|
}
|
private void init() {
|
setBounds(100, 100, 450, 300);
|
getContentPane().setLayout(new BorderLayout());
|
linkTypeTree = new LinkTypeTree();
|
|
getContentPane().setLayout(new BorderLayout(0, 0));
|
|
bg = new ButtonGroup();
|
btmTree = new BtmTree();
|
JPanel panel = new JPanel();
|
getContentPane().add(panel, BorderLayout.CENTER);
|
panel.setLayout(new BorderLayout(0, 0));
|
|
JPanel radioBtn = new JPanel();
|
|
panel.add(radioBtn, BorderLayout.NORTH);
|
radioBtn.setLayout(new GridLayout(0, 2, 0, 0));
|
|
btmTerrBtn = new JRadioButton("业务类型树");
|
btmTerrBtn.setSelected(true);
|
radioBtn.add(btmTerrBtn);
|
|
linktypeTreeBtn = new JRadioButton("链接类型树");
|
radioBtn.add(linktypeTreeBtn);
|
|
bg.add(btmTerrBtn);
|
bg.add(linktypeTreeBtn);
|
|
treePanel = new JPanel();
|
treePanel.setLayout(new BorderLayout());
|
treePanel.add(btmTree);
|
|
treescrollPane = new JScrollPane();
|
treescrollPane.setViewportView(treePanel);
|
panel.add(treescrollPane, 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() {
|
|
@Override
|
public void actionPerformed(ActionEvent e) {
|
DefaultMutableTreeNode lastPathComponent = null;
|
if(typeFlag==0){
|
lastPathComponent = (DefaultMutableTreeNode) btmTree.getSelectionPath().getLastPathComponent();
|
}else if(typeFlag==1){
|
lastPathComponent = (DefaultMutableTreeNode) linkTypeTree.getSelectionPath().getLastPathComponent();
|
}
|
|
if(lastPathComponent == null){
|
VCIOptionPane.showMessage(LogonApplication.frame, "请选择类型!");
|
return;
|
}
|
treeObject = lastPathComponent.getUserObject();
|
if(treeObject instanceof String){
|
VCIOptionPane.showMessage(LogonApplication.frame, "请选择类型节点!");
|
return;
|
}
|
dispose();
|
}
|
});
|
buttonPane.add(okButton);
|
}
|
{
|
JButton cancelButton = new JButton("关闭");
|
cancelButton.addActionListener(new ActionListener() {
|
|
@Override
|
public void actionPerformed(ActionEvent arg0) {
|
dispose();
|
}
|
});
|
buttonPane.add(cancelButton);
|
}
|
}
|
|
private void actionListener(){
|
btmTerrBtn.addActionListener(new ActionListener() {
|
|
@Override
|
public void actionPerformed(ActionEvent arg0) {
|
treePanel.removeAll();
|
treePanel.add(btmTree);
|
typeFlag = 0;
|
treePanel.updateUI();
|
}
|
|
|
});
|
|
linktypeTreeBtn.addActionListener(new ActionListener() {
|
|
@Override
|
public void actionPerformed(ActionEvent arg0) {
|
treePanel.removeAll();
|
treePanel.add(linkTypeTree);
|
typeFlag = 1;
|
treePanel.updateUI();
|
}
|
});
|
}
|
}
|