package com.vci.client.omd.btm.ui;
|
|
import java.awt.BorderLayout;
|
import java.awt.Color;
|
import java.awt.Dimension;
|
import java.awt.FlowLayout;
|
import java.awt.GridBagConstraints;
|
import java.awt.GridBagLayout;
|
import java.awt.Insets;
|
import java.awt.Toolkit;
|
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionListener;
|
import java.awt.event.ItemEvent;
|
import java.awt.event.ItemListener;
|
import java.net.MalformedURLException;
|
import java.net.URL;
|
import java.util.ArrayList;
|
import java.util.Arrays;
|
import java.util.Collections;
|
import java.util.Enumeration;
|
import java.util.HashMap;
|
import java.util.Iterator;
|
import java.util.List;
|
|
import javax.swing.BorderFactory;
|
import javax.swing.ButtonGroup;
|
import javax.swing.ImageIcon;
|
import javax.swing.JButton;
|
import javax.swing.JCheckBox;
|
import javax.swing.JComboBox;
|
import javax.swing.JLabel;
|
import javax.swing.JOptionPane;
|
import javax.swing.JPanel;
|
import javax.swing.JRadioButton;
|
import javax.swing.JScrollPane;
|
import javax.swing.JSplitPane;
|
import javax.swing.JTextField;
|
import javax.swing.JTree;
|
import javax.swing.border.EmptyBorder;
|
import javax.swing.event.TreeSelectionEvent;
|
import javax.swing.event.TreeSelectionListener;
|
import javax.swing.table.DefaultTableModel;
|
import javax.swing.tree.DefaultMutableTreeNode;
|
import javax.swing.tree.DefaultTreeModel;
|
import javax.swing.tree.TreeModel;
|
import javax.swing.tree.TreeNode;
|
import javax.swing.tree.TreePath;
|
import javax.swing.tree.TreeSelectionModel;
|
|
import org.jdesktop.swingx.JXTable;
|
import org.jdesktop.swingx.decorator.HighlighterFactory;
|
|
import com.vci.corba.omd.btm.BtmItem;
|
import com.vci.corba.omd.ltm.LinkType;
|
import com.vci.mw.InvocationUtility;
|
import com.vci.client.LogonApplication;
|
import com.vci.client.common.providers.ServiceProvider;
|
import com.vci.client.omd.attribpool.toOutside.ApTableForBtm;
|
import com.vci.client.omd.btm.resource.BtmTool;
|
import com.vci.client.omd.btm.toOutside.InterBtmManager;
|
import com.vci.client.omd.btm.wrapper.BtmItemWrapper;
|
import com.vci.client.omd.provider.LinkTypeProvider;
|
import com.vci.client.omd.ui.OmdTreeCellRenderer;
|
import com.vci.client.ui.image.BundleImage;
|
import com.vci.client.ui.util.PostorderEnumeration;
|
import com.vci.corba.common.VCIError;
|
import com.vci.omd.utils.BTComparator;
|
import com.vci.omd.constants.FileObjectType;
|
|
public class BtmPanel extends JPanel {
|
|
/**
|
*
|
*/
|
private static final long serialVersionUID = -5332052240477336532L;
|
|
private static BtmPanel btmPanel = null;
|
// add by caill
|
private JPanel northPanel, centerPanel, treePanel, mainPanel, leftNorthPanel, left;
|
// end
|
private JButton btnCreate, btnModify, btnDelete, btnUsed, btnConsistencyCheck, btnCreateView;
|
private JTree btmTree;
|
private BtmItem[] btmArray = null;
|
private HashMap<String, ArrayList<BtmItem>> btmListMap = null;
|
private DefaultMutableTreeNode rootNode;
|
// add by caill
|
private JTextField textField;
|
private JTextField textField2;
|
private JButton sel;
|
private JButton sel2;
|
// end
|
private JPanel mp_northPanel, mp_centerPanel, mpn_leftPanel, mpn_centerPanel, mpc_centerPanel, mpc_eastPanel,
|
mp_southPanel, mpc_northPanel;
|
private JTextField tfName, tfLabel, tfFName, tfLCycle, tfRevRuleName;
|
private JCheckBox chbAbstract, chbRevInput;
|
private JTextField taDescrip;
|
// private JTextArea taDescrip;
|
private JRadioButton rdLevel0, rdLevel1, rdLevel2, rdVer123, rdVerABC, rdVer012;
|
private ButtonGroup rdLevelGroup, rdVerGroup;
|
private JButton btnFName, btnLCycle, btnRevRuleName, btnImage, btnRemove, btnAdd, btnOK, btnCancel;
|
private JComboBox combDelimiter;
|
private JLabel lblFName, lblImage;
|
private String imageURL = "";
|
private ApTableForBtm apTable;
|
private JScrollPane scrollPanel;
|
private String selectedNodeName = "";
|
private HashMap<String, List<String>> nameMap = null;
|
private ArrayList<String> nameList = null;
|
private BtmItem btmItem = null;
|
private JTextField tfImplClass;
|
/**
|
* 0:浏览; 1:创建; 2:修改
|
*/
|
private int flag = 0;
|
/**
|
* 记录从业务类型中移除的属性
|
*/
|
private ArrayList<String> removeAbList = new ArrayList<String>();
|
|
private JLabel lblRevRuleName;
|
|
private JLabel lblDelimiter;
|
|
private JLabel lblVer;
|
|
private JPanel mpn_rightPanel;
|
|
private JPanel lcNorth;
|
|
private JPanel lcCenter;
|
|
private JScrollPane lcnScrollPanel;
|
|
private JPanel lcnSouth;
|
|
private JButton btnLCAdd;
|
|
private JButton btnLCRemove;
|
|
private JXTable lcTable;
|
|
private DefaultTableModel lcTableModel;
|
private JButton btnDeleteData, btnDeleteTypes;
|
|
//private JButton btnXml2DB;
|
|
private JButton btnExp;
|
|
private JButton btnImp;
|
|
private JButton btnSetIndex;
|
|
BtmPanel() {
|
initUI();
|
initBtmTree();
|
updateBtmInfo(null);
|
updateNameMap();
|
updateApTable();
|
addListener();
|
}
|
|
String[] node = new String[2];
|
|
public JTree getBtmTree() {
|
return btmTree;
|
}
|
|
public void setBtmTree(JTree btmTree) {
|
this.btmTree = btmTree;
|
}
|
|
public static void cleanInstance() {
|
btmPanel = null;
|
}
|
|
public static BtmPanel getInstance() {
|
if (btmPanel == null) {
|
btmPanel = new BtmPanel();
|
}
|
|
return btmPanel;
|
}
|
|
private void initUI() {
|
this.setBackground(Color.WHITE);
|
this.setLayout(new BorderLayout(0, 0));
|
|
// northPanel
|
northPanel = new JPanel();
|
// FlowLayout是panel的默认布局管理器
|
FlowLayout flowLayout = (FlowLayout) northPanel.getLayout();
|
flowLayout.setAlignment(FlowLayout.LEFT);
|
this.add(northPanel, BorderLayout.NORTH);
|
// add by caill
|
sel = new JButton("定位");
|
// end
|
btnCreate = new JButton("创建");
|
btnModify = new JButton("修改");
|
btnDelete = new JButton("删除");
|
btnUsed = new JButton("查看应用范围");
|
btnConsistencyCheck = new JButton("一致性检查");
|
btnConsistencyCheck.setToolTipText("检查类型与数据库中表的一致性");
|
btnCreateView = new JButton("创建视图");
|
btnDeleteData = new JButton("删除数据");
|
btnDeleteData.setToolTipText("删除数据库中对象数据");
|
btnDeleteTypes = new JButton("删除全部类型");
|
btnDeleteTypes.setToolTipText("删除类型,表,属性等");
|
//btnXml2DB = new JButton("模型迁移");
|
btnExp = new JButton("导出");
|
btnImp = new JButton("导入");
|
btnSetIndex = new JButton("创建索引");
|
northPanel.add(btnCreate);
|
northPanel.add(btnModify);
|
northPanel.add(btnDelete);
|
northPanel.add(btnUsed);
|
northPanel.add(btnConsistencyCheck);
|
northPanel.add(btnCreateView);
|
northPanel.add(btnDeleteData);
|
northPanel.add(btnDeleteTypes);
|
//northPanel.add(btnXml2DB);
|
northPanel.add(btnExp);
|
northPanel.add(btnImp);
|
northPanel.add(btnSetIndex);
|
// centerPanel
|
centerPanel = new JPanel();
|
this.add(centerPanel, BorderLayout.CENTER);
|
centerPanel.setLayout(new GridBagLayout());
|
GridBagConstraints g = new GridBagConstraints();
|
// add by caill 增加了新的JPanel为left
|
left = new JPanel();
|
left.setLayout(new GridBagLayout());
|
// end
|
g.gridx = 0;
|
g.gridy = 0;
|
g.weightx = 1.0;
|
g.weighty = 1.0;
|
g.fill = GridBagConstraints.BOTH;
|
// add by caill
|
// 搜索框的设置
|
GridBagConstraints gbc = new GridBagConstraints();
|
gbc.gridx = 0;
|
gbc.gridy = 0;
|
gbc.weightx = 0.7;
|
gbc.weighty = 0;
|
gbc.fill = GridBagConstraints.HORIZONTAL;
|
// end
|
// 用于显示业务类型树
|
treePanel = new JPanel();
|
treePanel.setLayout(new GridBagLayout());
|
// add by caill增加了新的JPanel为leftNorthPanel
|
leftNorthPanel = new JPanel();
|
leftNorthPanel.setLayout(new GridBagLayout());
|
// end
|
rootNode = new DefaultMutableTreeNode("业务类型树");
|
btmTree = new JTree(rootNode);
|
btmTree.setCellRenderer(new OmdTreeCellRenderer());
|
btmTree.setAutoscrolls(true);
|
// add by caill
|
// 添加搜索框
|
textField = new JTextField();
|
// end
|
// 设置单选模式
|
btmTree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
|
// add by caill 在新添加的leftNorthPanel中添加定位框和定位按钮
|
leftNorthPanel.add(textField, gbc);
|
leftNorthPanel.add(sel);
|
// end
|
treePanel.add(new JScrollPane(btmTree), g);
|
// add by caill
|
sel.addActionListener(new ActionListener() {
|
@Override
|
public void actionPerformed(ActionEvent e) {
|
String test = textField.getText().trim();
|
DefaultTreeModel model = (DefaultTreeModel) btmTree.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 BtmItemWrapper) {
|
BtmItemWrapper wrapper = (BtmItemWrapper) element.getUserObject();
|
|
if (wrapper != null && wrapper.btmItem != null && wrapper.btmItem.name.equals(test)) {
|
TreeNode[] path = element.getPath();
|
TreePath treePath = new TreePath(path);
|
btmTree.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) btmTree.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 BtmItemWrapper) {
|
BtmItemWrapper wrapper = (BtmItemWrapper) element.getUserObject();
|
|
if (wrapper != null && wrapper.btmItem != null && wrapper.btmItem.name.equals(test)) {
|
TreeNode[] path = element.getPath();
|
TreePath treePath = new TreePath(path);
|
btmTree.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
|
|
// mainPanel位于右侧,用于创建,修改,显示业务类型
|
mainPanel = new JPanel();
|
mainPanel.setLayout(new BorderLayout());
|
// add by caill start 将leftNorthPanel和treePanel放入到left中
|
left.setLayout(new BorderLayout());
|
left.add(leftNorthPanel, BorderLayout.NORTH);
|
left.add(treePanel, BorderLayout.CENTER);
|
JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, left, mainPanel);
|
// add by caill end
|
splitPane.setDividerLocation(Toolkit.getDefaultToolkit().getScreenSize().width / 5);
|
splitPane.setOneTouchExpandable(true);
|
centerPanel.add(splitPane, g);
|
|
// 业务类型的基本信息
|
mp_northPanel = new JPanel();
|
mp_northPanel.setBorder(BorderFactory.createTitledBorder("基本信息"));
|
JScrollPane tempSP1 = new JScrollPane();
|
tempSP1.setViewportView(mp_northPanel);
|
// 业务类型属性列表
|
mp_centerPanel = new JPanel();
|
mp_centerPanel.setBorder(BorderFactory.createTitledBorder("属性列表"));
|
|
mp_southPanel = new JPanel();
|
mainPanel.add(tempSP1, BorderLayout.NORTH);
|
mainPanel.add(mp_centerPanel, BorderLayout.CENTER);
|
mainPanel.add(mp_southPanel, BorderLayout.SOUTH);
|
|
// 基本信息
|
mpn_leftPanel = new JPanel();
|
// 版本规则
|
mpn_centerPanel = new JPanel();
|
// 生命周期
|
mpn_rightPanel = new JPanel();
|
mp_northPanel.setLayout(new GridBagLayout());
|
mp_northPanel.add(mpn_leftPanel,
|
getGBC(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, 3));
|
mp_northPanel.add(mpn_centerPanel,
|
getGBC(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, 3));
|
mp_northPanel.add(mpn_rightPanel,
|
getGBC(2, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, 3));
|
|
// GridBagConstraints g_mpn = new GridBagConstraints();
|
// g_mpn.gridx = 0;
|
// g_mpn.gridy = 0;
|
// g_mpn.weighty = 1.0;
|
// mp_northPanel.add(mpn_leftPanel, g_mpn);
|
// g_mpn.gridx = 1;
|
// mp_northPanel.add(mpn_centerPanel, g_mpn);
|
// g_mpn.gridx = 2;
|
// g_mpn.weightx = GridBagConstraints.REMAINDER;
|
// mp_northPanel.add(mpn_rightPanel, g_mpn);
|
|
// 基本信息----start----
|
int gridy = 0;
|
mpn_leftPanel.setLayout(new GridBagLayout());
|
mpn_leftPanel.setBorder(BorderFactory.createTitledBorder("基本信息"));
|
mpn_leftPanel.add(new JLabel("类型名称"),
|
getGBC(0, gridy, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, 3));
|
tfName = new JTextField(20);
|
mpn_leftPanel.add(tfName,
|
getGBC(1, gridy, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, 3));
|
chbAbstract = new JCheckBox("不可实例化");
|
mpn_leftPanel.add(chbAbstract,
|
getGBC(2, gridy, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, 3));
|
|
gridy++;
|
mpn_leftPanel.add(new JLabel("标签"),
|
getGBC(0, gridy, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, 3));
|
tfLabel = new JTextField(20);
|
mpn_leftPanel.add(tfLabel,
|
getGBC(1, gridy, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, 3));
|
|
gridy++;
|
lblFName = new JLabel("继承自");
|
mpn_leftPanel.add(lblFName,
|
getGBC(0, gridy, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, 3));
|
tfFName = new JTextField(20);
|
mpn_leftPanel.add(tfFName,
|
getGBC(1, gridy, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, 3));
|
btnFName = new JButton("...");
|
mpn_leftPanel.add(btnFName,
|
getGBC(2, gridy, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, 3));
|
|
gridy++;
|
JLabel label = new JLabel("实现类");
|
mpn_leftPanel.add(label, getGBC(0, gridy, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, 3));
|
tfImplClass = new JTextField(20);
|
mpn_leftPanel.add(tfImplClass,
|
getGBC(1, gridy, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, 3));
|
|
gridy++;
|
mpn_leftPanel.add(new JLabel("描述"),
|
getGBC(0, gridy, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, 3));
|
// taDescrip = new JTextArea();
|
taDescrip = new JTextField();
|
// taDescrip.setBorder(LineBorder.createBlackLineBorder());
|
// taDescrip.setPreferredSize(new Dimension(180, 50));
|
mpn_leftPanel.add(taDescrip,
|
getGBC(1, gridy, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, 3));
|
|
gridy++;
|
mpn_leftPanel.add(new JLabel("图标"),
|
getGBC(0, gridy, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, 3));
|
btnImage = new JButton("...");
|
lblImage = new JLabel();
|
mpn_leftPanel.add(lblImage,
|
getGBC(1, gridy, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, 3));
|
mpn_leftPanel.add(btnImage,
|
getGBC(2, gridy, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, 3));
|
|
///////////////////////////////////////////////////////////
|
// GridBagConstraints g_mpnl = new GridBagConstraints();
|
// g_mpnl.insets = new Insets(5, 5, 5, 5);
|
// g_mpnl.anchor = GridBagConstraints.EAST;
|
// g_mpnl.gridx = 0;
|
// g_mpnl.gridy = 0;
|
// mpn_leftPanel.add(new JLabel("类型名称"), g_mpnl);
|
|
// tfName = new JTextField(20);
|
// g_mpnl.gridx = 1;
|
// mpn_leftPanel.add(tfName, g_mpnl);
|
//
|
// chbAbstract = new JCheckBox("不可实例化");
|
// g_mpnl.gridx = 2;
|
// g_mpnl.gridwidth = GridBagConstraints.REMAINDER;
|
// mpn_leftPanel.add(chbAbstract, g_mpnl);
|
// g_mpnl.gridx = 0;
|
// g_mpnl.gridy = 1;
|
// g_mpnl.gridwidth = 1;
|
// mpn_leftPanel.add(new JLabel("标签"), g_mpnl);
|
// GridBagConstraints g_mpnl1 = new GridBagConstraints();
|
// g_mpnl1.insets = new Insets(5, 5, 5, 5);
|
// g_mpnl1.anchor = GridBagConstraints.WEST;
|
// g_mpnl1.gridx = 1;
|
// g_mpnl1.gridy = 1;
|
// g_mpnl1.gridwidth = GridBagConstraints.REMAINDER;
|
// tfLabel = new JTextField(20);
|
// mpn_leftPanel.add(tfLabel, g_mpnl1);
|
// lblFName = new JLabel("继承自");
|
// g_mpnl1.gridx = 1;
|
// g_mpnl.gridy = 2;
|
// mpn_leftPanel.add(lblFName, g_mpnl);
|
// tfFName = new JTextField(20);
|
// tfFName.setPreferredSize(new Dimension(180, 25));
|
// g_mpnl1.gridy = 2;
|
// g_mpnl1.gridwidth = 1;
|
// mpn_leftPanel.add(tfFName, g_mpnl1);
|
// g_mpnl1.gridx = 2;
|
// g_mpnl1.gridwidth = 0;
|
// btnFName = new JButton("...");
|
// mpn_leftPanel.add(btnFName, g_mpnl1);
|
// g_mpnl.gridy = 3;
|
// mpn_leftPanel.add(new JLabel("实现类"), g_mpnl);
|
// tfImplClass = new JTextField(20);
|
// tfImplClass.setPreferredSize(new Dimension(180, 25));
|
|
// g_mpnl1.gridx = 1;
|
// g_mpnl1.gridy = 3;
|
// g_mpnl1.gridwidth = 0;
|
// mpn_leftPanel.add(tfImplClass, g_mpnl1);
|
// g_mpnl1.gridwidth = 0;
|
// g_mpnl1.gridx = 1;
|
// g_mpnl.gridy = 4;
|
// mpn_leftPanel.add(new JLabel("描述"), g_mpnl);
|
// taDescrip = new JTextArea();
|
// taDescrip.setPreferredSize(new Dimension(180, 50));
|
// g_mpnl1.gridy = 4;
|
// mpn_leftPanel.add(new JScrollPane(taDescrip), g_mpnl1);
|
// btnImage = new JButton("图标");
|
// g_mpnl.gridy = 5;
|
// mpn_leftPanel.add(btnImage, g_mpnl);
|
// lblImage = new JLabel();
|
// g_mpnl1.gridy = 5;
|
// mpn_leftPanel.add(lblImage, g_mpnl1);
|
// 基本信息----end----
|
|
// 版本规则----start----
|
mpn_centerPanel.setLayout(new GridBagLayout());
|
mpn_centerPanel.setBorder(BorderFactory.createTitledBorder("版本规则"));
|
GridBagConstraints g_mpnCen = new GridBagConstraints();
|
g_mpnCen.anchor = GridBagConstraints.WEST;
|
g_mpnCen.insets = new Insets(5, 5, 5, 5);
|
|
rdLevel0 = new JRadioButton("不可修订");
|
rdLevel1 = new JRadioButton("采用一级版本管理");
|
rdLevel2 = new JRadioButton("采用二级版本管理");
|
|
rdLevelGroup = new ButtonGroup();
|
rdLevelGroup.add(rdLevel0);
|
rdLevelGroup.add(rdLevel1);
|
rdLevelGroup.add(rdLevel2);
|
rdLevel2.setSelected(true);
|
g_mpnCen.gridx = 0;
|
g_mpnCen.gridy = 0;
|
mpn_centerPanel.add(rdLevel0, g_mpnCen);
|
g_mpnCen.gridx = 1;
|
mpn_centerPanel.add(rdLevel1, g_mpnCen);
|
g_mpnCen.gridx = 2;
|
g_mpnCen.gridwidth = GridBagConstraints.REMAINDER;
|
mpn_centerPanel.add(rdLevel2, g_mpnCen);
|
g_mpnCen.gridx = 0;
|
g_mpnCen.gridy = 1;
|
g_mpnCen.gridwidth = 1;
|
|
lblRevRuleName = new JLabel("版本号规则");
|
mpn_centerPanel.add(lblRevRuleName, g_mpnCen);
|
tfRevRuleName = new JTextField(15);
|
tfRevRuleName.setEditable(false);
|
g_mpnCen.gridx = 1;
|
mpn_centerPanel.add(tfRevRuleName, g_mpnCen);
|
g_mpnCen.gridx = 2;
|
btnRevRuleName = new JButton("...");
|
mpn_centerPanel.add(btnRevRuleName, g_mpnCen);
|
if (rdLevel0.isSelected() || rdLevel1.isSelected()) {
|
btnRevRuleName.setVisible(false);
|
}
|
chbRevInput = new JCheckBox("手工输入");
|
g_mpnCen.gridx = 3;
|
g_mpnCen.gridwidth = 0;
|
mpn_centerPanel.add(chbRevInput, g_mpnCen);
|
g_mpnCen.gridx = 0;
|
g_mpnCen.gridy = 2;
|
g_mpnCen.gridwidth = 1;
|
lblDelimiter = new JLabel("分隔符");
|
mpn_centerPanel.add(lblDelimiter, g_mpnCen);
|
combDelimiter = new JComboBox();
|
combDelimiter.addItem(".");
|
combDelimiter.addItem("-");
|
combDelimiter.addItem("");
|
combDelimiter.setPreferredSize(tfRevRuleName.getPreferredSize());
|
g_mpnCen.gridx = 1;
|
g_mpnCen.gridwidth = 0;
|
mpn_centerPanel.add(combDelimiter, g_mpnCen);
|
g_mpnCen.gridx = 0;
|
g_mpnCen.gridy = 3;
|
lblVer = new JLabel("版次号规则");
|
mpn_centerPanel.add(lblVer, g_mpnCen);
|
g_mpnCen.gridwidth = 1;
|
g_mpnCen.gridy = 4;
|
rdVer123 = new JRadioButton("1.2.3...");
|
rdVerABC = new JRadioButton("a.b.c...");
|
rdVer012 = new JRadioButton("0.1.2...");
|
rdVerGroup = new ButtonGroup();
|
rdVerGroup.add(rdVer123);
|
rdVerGroup.add(rdVerABC);
|
rdVerGroup.add(rdVer012);
|
rdVer123.setSelected(true);
|
|
mpn_centerPanel.add(rdVer123, g_mpnCen);
|
g_mpnCen.gridx = 1;
|
mpn_centerPanel.add(rdVerABC, g_mpnCen);
|
g_mpnCen.gridx = 2;
|
g_mpnCen.gridwidth = 0;
|
mpn_centerPanel.add(rdVer012, g_mpnCen);
|
// 版本规则----end----
|
|
// 生命周期----start----
|
mpn_rightPanel.setLayout(new BorderLayout());
|
mpn_rightPanel.setPreferredSize(mpn_leftPanel.getPreferredSize());
|
mpn_rightPanel.setBorder(BorderFactory.createTitledBorder("生命周期"));
|
lcNorth = new JPanel();
|
lcCenter = new JPanel();
|
mpn_rightPanel.add(lcNorth, BorderLayout.NORTH);
|
mpn_rightPanel.add(lcCenter, BorderLayout.CENTER);
|
|
lcNorth.setLayout(new FlowLayout(FlowLayout.LEFT));
|
tfLCycle = new JTextField(25);
|
btnLCycle = new JButton("...");
|
|
lcNorth.setLayout(new GridBagLayout());
|
GridBagConstraints glcn = new GridBagConstraints();
|
glcn.anchor = GridBagConstraints.WEST;
|
glcn.gridx = 0;
|
glcn.gridy = 0;
|
glcn.weightx = 0.0;
|
glcn.weighty = 0.0;
|
glcn.fill = GridBagConstraints.NONE;
|
lcNorth.add(new JLabel("生命周期"), glcn);
|
|
glcn.gridx = 1;
|
glcn.anchor = GridBagConstraints.CENTER;
|
glcn.weightx = 1.0;
|
glcn.fill = GridBagConstraints.BOTH;
|
lcNorth.add(tfLCycle, glcn);
|
|
glcn.gridx = 2;
|
glcn.anchor = GridBagConstraints.WEST;
|
glcn.weightx = 0.0;
|
glcn.fill = GridBagConstraints.NONE;
|
btnLCycle.setPreferredSize(new Dimension(35, 23));
|
lcNorth.add(btnLCycle, glcn);
|
|
lcCenter.setLayout(new BorderLayout());
|
lcnScrollPanel = new JScrollPane();
|
lcnSouth = new JPanel();
|
lcnSouth.setLayout(new FlowLayout(FlowLayout.LEFT));
|
btnLCAdd = new JButton("增加");
|
btnLCRemove = new JButton("移除");
|
lcnSouth.add(btnLCAdd);
|
lcnSouth.add(btnLCRemove);
|
lcCenter.add(lcnSouth, BorderLayout.NORTH);
|
|
lcTableModel = new DefaultTableModel();
|
lcTableModel.setColumnIdentifiers(new String[] { "备选生命周期列表" });
|
lcTable = new JXTable(lcTableModel);
|
lcTable.setAutoscrolls(true);
|
lcTable.setHorizontalScrollEnabled(true);
|
lcTable.setSortable(false);
|
lcTable.setHighlighters(HighlighterFactory.createAlternateStriping());
|
lcnScrollPanel.setViewportView(lcTable);
|
lcCenter.add(lcnScrollPanel, BorderLayout.CENTER);
|
// 生命周期----end----
|
|
mp_centerPanel.setLayout(new BorderLayout());
|
// 属性列表
|
mpc_centerPanel = new JPanel();
|
// 增加,移除按钮
|
mpc_eastPanel = new JPanel();
|
// add by caill
|
// 查询框
|
mpc_northPanel = new JPanel();
|
// 在mp_centerPanel里添加mpc_northPanel
|
mp_centerPanel.add(mpc_northPanel, BorderLayout.NORTH);
|
// end
|
mp_centerPanel.add(mpc_centerPanel, BorderLayout.CENTER);
|
//mp_centerPanel.add(mpc_eastPanel, BorderLayout.EAST);
|
// add by caill start
|
// 添加查询框和查询按钮
|
textField2 = new JTextField(50);
|
sel2 = new JButton("查询");
|
// 搜索框的设置
|
GridBagConstraints gbcs = new GridBagConstraints();
|
gbcs.gridx = 0;
|
gbcs.gridy = 0;
|
gbcs.weightx = 0;
|
gbcs.weighty = 0;
|
gbcs.fill = GridBagConstraints.HORIZONTAL;
|
mpc_northPanel.setLayout(new GridBagLayout());
|
// add by caill start 2015.11.24 将属性列表的查询拿掉,以后如有需要,可直接放开注释即可
|
/*
|
* mpc_northPanel.add(new JLabel("属性名 "),gbcs);
|
* mpc_northPanel.add(textField2); mpc_northPanel.add(sel2);
|
*/
|
// add by caill end
|
// add by caill start
|
// 给查询按钮添加事件,根据updateNameMap()方法做了修改
|
sel2.addActionListener(new ActionListener() {
|
@Override
|
public void actionPerformed(ActionEvent e) {
|
sel();
|
}
|
});
|
// 为查询框添加键盘事件
|
textField2.addActionListener(new ActionListener() {
|
@Override
|
public void actionPerformed(ActionEvent e) {
|
sel();
|
}
|
});
|
// add by caill end
|
mpc_centerPanel.setBorder(new EmptyBorder(20, 5, 0, 5));
|
// end
|
mpc_centerPanel.setAutoscrolls(true);
|
mpc_centerPanel.setLayout(new BorderLayout(5, 5));
|
scrollPanel = new JScrollPane();
|
|
mpc_centerPanel.add(mpc_eastPanel, BorderLayout.NORTH);
|
mpc_centerPanel.add(scrollPanel, BorderLayout.CENTER);
|
|
FlowLayout fl = new FlowLayout();
|
fl.setAlignment(FlowLayout.LEFT);
|
mpc_eastPanel.setLayout(fl);
|
// GridBagConstraints mpce_g = new GridBagConstraints();
|
// mpce_g.anchor = GridBagConstraints.ABOVE_BASELINE;
|
// mpce_g.insets = new Insets(5, 0, 5, 0);
|
// mpce_g.gridx = 0;
|
// mpce_g.gridy = 0;
|
// mpce_g.gridwidth = GridBagConstraints.REMAINDER;
|
btnAdd = new JButton("增加");
|
btnRemove = new JButton("移除");
|
// mpc_eastPanel.add(btnAdd, mpce_g);
|
// mpce_g.gridx = 1;
|
// mpc_eastPanel.add(btnRemove, mpce_g);
|
// 确定, 取消按钮
|
btnOK = new JButton("确定");
|
btnCancel = new JButton("取消");
|
mp_southPanel.add(btnOK);
|
mp_southPanel.add(btnCancel);
|
|
}
|
|
private GridBagConstraints getGBC(int gridx, int gridy, int gridwidth, int gridheight, double weightx,
|
double weighty, int anchor, int fill, int padxy) {
|
return new GridBagConstraints(gridx, gridy, gridwidth, gridheight, weightx, weighty, anchor, fill,
|
new Insets(padxy, padxy, padxy, padxy), padxy, padxy);
|
}
|
|
private void addListener() {
|
rdLevel0.addItemListener(new ItemListener() {
|
|
@Override
|
public void itemStateChanged(ItemEvent e) {
|
setVisibleForRev();
|
}
|
});
|
rdLevel1.addItemListener(new ItemListener() {
|
|
@Override
|
public void itemStateChanged(ItemEvent e) {
|
setVisibleForRev();
|
}
|
});
|
|
rdLevel2.addItemListener(new ItemListener() {
|
|
@Override
|
public void itemStateChanged(ItemEvent e) {
|
setVisibleForRev();
|
}
|
});
|
btnLCycle.addActionListener(new ActionListener() {
|
|
@Override
|
public void actionPerformed(ActionEvent e) {
|
LCycleSelectDialog dialog = new LCycleSelectDialog(getLCList());
|
dialog.setVisible(true);
|
String selectName = dialog.getSelectName();
|
if (selectName != null && !selectName.equals("")) {
|
tfLCycle.setText(selectName);
|
}
|
}
|
});
|
|
btnRevRuleName.addActionListener(new ActionListener() {
|
|
@Override
|
public void actionPerformed(ActionEvent e) {
|
RevisionSelectDialog dialog = new RevisionSelectDialog();
|
dialog.setVisible(true);
|
String selectName = dialog.getSelectName();
|
if (!selectName.equals("")) {
|
tfRevRuleName.setText(selectName);
|
}
|
}
|
});
|
|
chbRevInput.addItemListener(new ItemListener() {
|
|
@Override
|
public void itemStateChanged(ItemEvent e) {
|
if (chbRevInput.isSelected()) {
|
tfRevRuleName.setEditable(false);
|
tfRevRuleName.setText("");
|
btnRevRuleName.setEnabled(false);
|
} else {
|
btnRevRuleName.setEnabled(true);
|
}
|
}
|
});
|
btmTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {
|
|
@Override
|
public void valueChanged(TreeSelectionEvent e) {
|
DefaultMutableTreeNode seletionNode = (DefaultMutableTreeNode) btmTree.getLastSelectedPathComponent();
|
if (seletionNode == null) {
|
return;
|
}
|
if (seletionNode.getUserObject() instanceof BtmItemWrapper) {
|
selectedNodeName = ((BtmItemWrapper) seletionNode.getUserObject()).btmItem.name;
|
if (flag != 0) {
|
removeAbList.clear();
|
nameList.clear();
|
flag = 0;
|
}
|
|
updateBtmInfo(((BtmItemWrapper) seletionNode.getUserObject()).btmItem);
|
// } else if (seletionNode.getUserObject() instanceof BtmItemWrapper) {
|
// selectedNodeName = ((BtmItemWrapper) seletionNode.getUserObject()).btmItem.name;
|
// updateNameMap();
|
// updateApTable();
|
} else {
|
selectedNodeName = "";
|
updateBtmInfo(null);
|
}
|
// ========add by guo========
|
for (int i = 0; i < node.length; i++) {
|
if (node[i] == (null)) {
|
node[i] = selectedNodeName;
|
break;
|
}
|
}
|
if (!(node[1] == null)) {
|
statusChangeToFalse();
|
node[1] = null;
|
}
|
// ================
|
}
|
});
|
|
btnCreate.addActionListener(new ActionListener() {
|
|
@Override
|
public void actionPerformed(ActionEvent e) {
|
if (flag == 1) {
|
statusChangeToTrue();
|
return;
|
}
|
flag = 1;
|
btnRevRuleName.setEnabled(true);
|
DefaultMutableTreeNode seletionNode = (DefaultMutableTreeNode) btmTree.getLastSelectedPathComponent();
|
if (seletionNode == null) {
|
JOptionPane.showMessageDialog(getInstance(), "请选择父节点", "选择父节点", JOptionPane.ERROR_MESSAGE);
|
return;
|
}
|
if (seletionNode.getUserObject() instanceof BtmItemWrapper) {
|
selectedNodeName = ((BtmItemWrapper) seletionNode.getUserObject()).btmItem.name;
|
} else {
|
selectedNodeName = "";
|
}
|
updateBtmInfo(null);
|
}
|
});
|
|
btnModify.addActionListener(new ActionListener() {
|
|
@Override
|
public void actionPerformed(ActionEvent e) {
|
if (flag == 2) {
|
// 不是第一次按修改按钮的时候当业务类型中存在数据的时候,不能进行移除操作add by guo
|
statusChangeToTrue();
|
if (hasInstance(btmItem.name)) {
|
btnRemove.setVisible(false);
|
}
|
return;
|
}
|
flag = 2;
|
btnRevRuleName.setEnabled(true);
|
DefaultMutableTreeNode seletionNode = (DefaultMutableTreeNode) btmTree.getLastSelectedPathComponent();
|
if (seletionNode == null) {
|
JOptionPane.showMessageDialog(getInstance(), "请选择要修改的业务类型", "无业务类型", JOptionPane.WARNING_MESSAGE);
|
return;
|
}
|
nameList.clear();
|
removeAbList.clear();
|
if (seletionNode.getUserObject() instanceof BtmItemWrapper) {
|
updateBtmInfo(((BtmItemWrapper) seletionNode.getUserObject()).btmItem);
|
} else {
|
updateBtmInfo(null);
|
JOptionPane.showMessageDialog(getInstance(), "请选择要修改的业务类型", "无业务类型", JOptionPane.WARNING_MESSAGE);
|
return;
|
}
|
// 第一次点击修改按钮的时候,当业务类型中存在数据的时候,不能进行移除操作add by guo
|
if (hasInstance(((BtmItemWrapper) seletionNode.getUserObject()).btmItem.name)) {
|
btnRemove.setVisible(false);
|
}
|
}
|
});
|
|
btnDelete.addActionListener(new ActionListener() {
|
|
@Override
|
public void actionPerformed(ActionEvent e) {
|
DefaultMutableTreeNode seletionNode = (DefaultMutableTreeNode) btmTree.getLastSelectedPathComponent();
|
if (!seletionNode.isLeaf()) {
|
JOptionPane.showMessageDialog(getInstance(), "只能删除叶子节点", "禁止删除", JOptionPane.ERROR_MESSAGE);
|
return;
|
}
|
BtmItem bt = ((BtmItemWrapper) seletionNode.getUserObject()).btmItem;
|
String btmName = bt.name;
|
// 业务类型被链接类型使用, 不能删除
|
List<String> usedNameList = InterBtmManager.getInstance().getUsedNameList(btmName);
|
if (usedNameList != null && usedNameList.size() > 0) {
|
JOptionPane.showMessageDialog(getInstance(), "该类型已被链接类型使用,禁止删除", "禁止删除", JOptionPane.ERROR_MESSAGE);
|
return;
|
}
|
// 业务类型已经生成了业务对象, 不能删除
|
if (hasInstance(btmName)) {
|
JOptionPane.showMessageDialog(getInstance(), "该类型已有实例,禁止删除", "禁止删除", JOptionPane.ERROR_MESSAGE);
|
return;
|
}
|
Object[] options = { "Yes", "No" };
|
int option = JOptionPane.showOptionDialog(getInstance(), "确认是否删除业务类型\"" + btmName + "\"", "业务类型删除",
|
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[1]);
|
if (option != JOptionPane.YES_OPTION) {
|
return;
|
}
|
try {
|
// String tableName = OmdTools.getBTMTableName(btmName);
|
// String sql = "drop table " + tableName;
|
// boolean flag = DDLToolClient.getService().executeUpdateOracle(sql);
|
// if (!flag) {
|
// JOptionPane.showMessageDialog(getInstance(), "删除table失败", "删除table失败",
|
// JOptionPane.WARNING_MESSAGE);
|
// return;
|
// } else {
|
// JOptionPane.showMessageDialog(getInstance(), "删除table成功", "删除table成功",
|
// JOptionPane.WARNING_MESSAGE);
|
// }
|
// 先删除数据表,再删除类型
|
boolean deleteFlag = BtmClient.getService().deleteBtmItem(bt);
|
if (!deleteFlag) {
|
JOptionPane.showMessageDialog(getInstance(), "删除失败", "删除失败", JOptionPane.WARNING_MESSAGE);
|
} else {
|
JOptionPane.showMessageDialog(getInstance(), "删除成功", "删除成功", JOptionPane.INFORMATION_MESSAGE);
|
selectedNodeName = "";
|
initBtmTree();
|
btmTree.updateUI();
|
updateBtmInfo(null);
|
}
|
} catch (VCIError e1) {
|
e1.printStackTrace();
|
}
|
}
|
});
|
|
btnUsed.addActionListener(new ActionListener() {
|
|
@Override
|
public void actionPerformed(ActionEvent e) {
|
if (btmItem == null) {
|
JOptionPane.showMessageDialog(getInstance(), "请选择业务类型", "无业务类型", JOptionPane.WARNING_MESSAGE);
|
return;
|
}
|
UsedToDialog dialog = new UsedToDialog(btmItem.name);
|
dialog.setVisible(true);
|
}
|
});
|
btnConsistencyCheck.addActionListener(new ConsistencyCheckListener());
|
btnCreateView.addActionListener(new ActionListener() {
|
|
@Override
|
public void actionPerformed(ActionEvent e) {
|
try {
|
boolean createView = BtmClient.getService().createView();
|
if (createView) {
|
JOptionPane.showMessageDialog(getInstance(), "创建视图成功", "创建视图成功",
|
JOptionPane.INFORMATION_MESSAGE);
|
return;
|
} else {
|
JOptionPane.showMessageDialog(getInstance(), "创建视图失败", "创建视图失败", JOptionPane.WARNING_MESSAGE);
|
return;
|
}
|
} catch (VCIError e1) {
|
e1.printStackTrace();
|
}
|
}
|
});
|
// 修改继承类, 当业务类型存在实例时: 不能修改; 无实例时: 可以修改.
|
btnFName.addActionListener(new ActionListener() {
|
|
@Override
|
public void actionPerformed(ActionEvent e) {
|
if (btmItem == null) {
|
JOptionPane.showMessageDialog(getInstance(), "请选择业务类型", "无业务类型", JOptionPane.WARNING_MESSAGE);
|
return;
|
}
|
if (hasInstance(btmItem.fName)) {
|
JOptionPane.showMessageDialog(getInstance(), "该业务类型已有实例, 不能修改继承类型", "不能修改",
|
JOptionPane.WARNING_MESSAGE);
|
return;
|
}
|
|
FNameSelectDialog dialog = FNameSelectDialog.getInstance();
|
dialog.setBtmName(tfName.getText());
|
dialog.setVisible(true);
|
if (dialog.getFName().equals("业务类型树")) {
|
tfFName.setText("");
|
} else {
|
tfFName.setText(dialog.getFName());
|
}
|
|
}
|
});
|
|
// 图标选择框
|
btnImage.addActionListener(new ActionListener() {
|
|
@Override
|
public void actionPerformed(ActionEvent e) {
|
ImageSelectDialog dialog = ImageSelectDialog.getInstance();
|
dialog.setVisible(true);
|
imageURL = dialog.getImageURL();
|
updateImage(dialog.isTomcatPath());
|
}
|
});
|
|
btnOK.addActionListener(new ActionListener() {
|
@Override
|
public void actionPerformed(ActionEvent e) {
|
// 点击确定按钮之后,页面的样式和点击修改按钮之前一样add by guo
|
statusChangeToFalse();
|
// 创建业务类型
|
if (flag == 1) {
|
if (!checkName()) {
|
return;
|
}
|
if (!checkLifeCycle()) {
|
return;
|
}
|
if (!checkVersionInfo()) {
|
return;
|
}
|
BtmItem btmItem = new BtmItem();
|
btmItem.name = tfName.getText().toLowerCase();
|
if (chbAbstract.isSelected()) {
|
btmItem.isAbstract = true;
|
} else {
|
btmItem.isAbstract = false;
|
}
|
btmItem.label = tfLabel.getText();
|
btmItem.fName = selectedNodeName;
|
btmItem.implClass = tfImplClass.getText();
|
btmItem.shape = "";
|
btmItem.lifeCycle = tfLCycle.getText();
|
List<String> lcList = getLCList();
|
if (lcList != null) {
|
btmItem.lifeCycles = lcList.toArray(new String[0]);
|
} else {
|
btmItem.lifeCycles = new String[0];
|
}
|
btmItem.description = taDescrip.getText();
|
if (rdLevel0.isSelected()) {
|
btmItem.revLevel = 0;
|
} else if (rdLevel1.isSelected()) {
|
btmItem.revLevel = 1;
|
} else if (rdLevel2.isSelected()) {
|
btmItem.revLevel = 2;
|
}
|
btmItem.revRuleName = tfRevRuleName.getText();
|
if (chbRevInput.isSelected()) {
|
btmItem.revInput = true;
|
} else {
|
btmItem.revInput = false;
|
}
|
String deli = (String) combDelimiter.getSelectedItem();
|
btmItem.delimiter = (deli == null ? "" : deli);
|
if (rdVer123.isSelected()) {
|
btmItem.verRuleName = 0;
|
} else if (rdVerABC.isSelected()) {
|
btmItem.verRuleName = 1;
|
} else if (rdVer012.isSelected()) {
|
btmItem.verRuleName = 2;
|
}
|
if (imageURL == null || imageURL.equals("")) {
|
btmItem.imageName = imageURL;
|
} else if (basePathISURL()) {
|
String imageName = imageURL.substring(imageURL.indexOf("images/"));
|
btmItem.imageName = imageName;
|
} else {
|
btmItem.imageName = imageURL;
|
}
|
btmItem.apNameArray = nameMap.get("").toArray(new String[0]);
|
String userName = InvocationUtility.getInvocation().userName;
|
btmItem.creator = userName;
|
btmItem.modifier = userName;
|
try {
|
boolean addFlag = BtmClient.getService().addBtmItem(btmItem);
|
if (addFlag) {
|
JOptionPane.showMessageDialog(getInstance(), "创建业务类型成功", "创建成功",
|
JOptionPane.INFORMATION_MESSAGE);
|
initBtmTree();
|
btmTree.updateUI();
|
findInTree(btmItem.name);
|
flag = 0;
|
|
// // 生成创建该业务类型表的DDL
|
// String createSql = BtmProvider.getInstance().getCreateBTMTableSql(btmItem);
|
// String alterSql = BtmProvider.getInstance().getAddPKSql(btmItem.name);
|
// // 执行DDL
|
// boolean createFlag = DDLToolClient.getService().executeUpdateOracle(createSql);
|
// boolean alterFlag = DDLToolClient.getService().executeUpdateOracle(alterSql);
|
// if (!createFlag || !alterFlag) {
|
// JOptionPane.showMessageDialog(getInstance(), "创建业务类型Table失败", "创建Table失败",
|
// JOptionPane.INFORMATION_MESSAGE);
|
// return;
|
// } else {
|
// JOptionPane.showMessageDialog(getInstance(), "创建业务类型Table成功", "创建Table成功",
|
// JOptionPane.INFORMATION_MESSAGE);
|
// }
|
} else {
|
JOptionPane.showMessageDialog(getInstance(), "创建业务类型失败", "创建失败",
|
JOptionPane.INFORMATION_MESSAGE);
|
}
|
} catch (VCIError e1) {
|
e1.printStackTrace();
|
}
|
// 修改业务类型
|
} else if (flag == 2) {
|
if (btmItem == null) {
|
JOptionPane.showMessageDialog(getInstance(), "请选择要修改的业务类型", "无业务类型",
|
JOptionPane.WARNING_MESSAGE);
|
return;
|
}
|
if (!checkLifeCycle()) {
|
return;
|
}
|
if (!checkRevLevel()) {
|
return;
|
}
|
if (!checkVersionInfo()) {
|
return;
|
}
|
if (chbAbstract.isSelected()) {
|
btmItem.isAbstract = true;
|
} else {
|
btmItem.isAbstract = false;
|
}
|
btmItem.label = tfLabel.getText();
|
btmItem.fName = tfFName.getText();
|
btmItem.implClass = tfImplClass.getText();
|
btmItem.shape = "";
|
btmItem.lifeCycle = tfLCycle.getText();
|
List<String> lcList = getLCList();
|
if (lcList != null) {
|
btmItem.lifeCycles = lcList.toArray(new String[0]);
|
} else {
|
btmItem.lifeCycles = new String[0];
|
}
|
btmItem.description = taDescrip.getText();
|
if (rdLevel0.isSelected()) {
|
btmItem.revLevel = 0;
|
} else if (rdLevel1.isSelected()) {
|
btmItem.revLevel = 1;
|
} else if (rdLevel2.isSelected()) {
|
btmItem.revLevel = 2;
|
}
|
btmItem.revRuleName = tfRevRuleName.getText();
|
if (chbRevInput.isSelected()) {
|
btmItem.revInput = true;
|
} else {
|
btmItem.revInput = false;
|
}
|
String deli = (String) combDelimiter.getSelectedItem();
|
btmItem.delimiter = (deli == null ? "" : deli);
|
if (rdVer123.isSelected()) {
|
btmItem.verRuleName = 0;
|
} else if (rdVerABC.isSelected()) {
|
btmItem.verRuleName = 1;
|
} else if (rdVer012.isSelected()) {
|
btmItem.verRuleName = 2;
|
}
|
if (imageURL == null || imageURL.equals("")) {
|
btmItem.imageName = imageURL;
|
} else if (basePathISURL()) {
|
String imageName = imageURL.substring(imageURL.indexOf("images/"));
|
btmItem.imageName = imageName;
|
} else {
|
btmItem.imageName = imageURL;
|
}
|
btmItem.modifier = InvocationUtility.getInvocation().userName;
|
List<String> list = new ArrayList<String>();
|
List<String> list_ = nameMap.get(btmItem.name);
|
if (list_ != null) {
|
for (int i = 0; i < list_.size(); i++) {
|
String abName = list_.get(i);
|
if (abName != null && !abName.equals("")) {
|
list.add(abName);
|
}
|
}
|
}
|
list_ = nameMap.get("");
|
if (list_ != null) {
|
for (int i = 0; i < list_.size(); i++) {
|
String abName = list_.get(i);
|
if (abName != null && !abName.equals("")) {
|
list.add(abName);
|
}
|
}
|
}
|
// 当业务类型表中某属性已经有值, 不删除该属性, 将已经移除的属性添加回来
|
String[] unRemovableFields = null;
|
List<String> unRemovableFields_ = null;
|
try {
|
unRemovableFields = BtmClient.getService().getUnRemovableFields(btmItem.name, removeAbList.toArray(new String[0]));
|
} catch (VCIError e1) {
|
e1.printStackTrace();
|
}
|
if (removeAbList.size() > 0) {
|
if (hasInstance(btmItem.name)) {
|
JOptionPane.showMessageDialog(getInstance(), "业务类型已有实例, 只能删除没有数据的列", "只能删除没有数据的列", JOptionPane.INFORMATION_MESSAGE);
|
if (unRemovableFields != null && unRemovableFields.length > 0) {
|
unRemovableFields_ = Arrays.asList(unRemovableFields);
|
for (int i = 0; i < removeAbList.size(); i++) {
|
String abName = removeAbList.get(i);
|
if (unRemovableFields_.contains(abName)) {
|
if (!list.contains(abName)) {
|
list.add(abName);
|
}
|
nameMap.get(btmItem.name).add(abName);
|
}
|
}
|
}
|
}
|
}
|
|
// String[] oldApNameArray = btmItem.apNameArray;
|
btmItem.apNameArray = list.toArray(new String[0]);
|
try {
|
// // 修改业务类型之前先操作数据库,数据库操作成功后,才去修改业务类型
|
// ArrayList<String> addedAbList = getAddedApList(oldApNameArray, btmItem.apNameArray);
|
// if (addedAbList != null && addedAbList.size() != 0) {
|
// // 更新表btmName 增加属性
|
// String tableName = OmdTools.getBTMTableName(btmItem.name);
|
// String sql = "alter table " + tableName + " add(";
|
// for (int i = 0; i < addedAbList.size(); i++) {
|
// String abName = addedAbList.get(i);
|
// AttribItem abItem = null;
|
// try {
|
// abItem = APClient.getService().getAttribItemByName(abName);
|
// } catch (VCIError e1) {
|
// e1.printStackTrace();
|
// }
|
// sql += BtmTool.getInstance().getAbSql(abItem);
|
// }
|
// sql = sql.substring(0, sql.lastIndexOf(","));
|
// sql += ")";
|
// List<String> sqlList = new ArrayList<String>();
|
// sqlList.add(sql);
|
// // 更新btmItem的子类型表
|
// String[] childrenNames = BtmClient.getService().getChildrenNames(btmItem.name);
|
// for (String name : childrenNames) {
|
// String tableName_ = OmdTools.getBTMTableName(name);
|
// String sql_ = sql.replace(tableName, tableName_);
|
// sqlList.add(sql_);
|
// }
|
// boolean flag = DDLToolClient.getService()
|
// .batchExecuteUpdateOracle(sqlList.toArray(new String[0]));
|
// if (!flag) {
|
// JOptionPane.showMessageDialog(getInstance(), "增加业务类型Table列失败", "修改Table失败",
|
// JOptionPane.INFORMATION_MESSAGE);
|
// btmItem.apNameArray = oldApNameArray;
|
// return;
|
// } else {
|
// JOptionPane.showMessageDialog(getInstance(), "增加业务类型Table列成功", "修改Table成功",
|
// JOptionPane.INFORMATION_MESSAGE);
|
// }
|
// }
|
//
|
// // 没有业务对象时, 删除表中移除的属性
|
// if (removeAbList.size() > 0) {
|
// // 存在不可删除的列,删除removeAbList - 不可删除的列
|
// if (unRemovableFields_ != null && unRemovableFields_.size() > 0) {
|
// removeAbList.removeAll(unRemovableFields_);
|
// if (removeAbList.size() > 0) {
|
// String tableName = OmdTools.getBTMTableName(btmItem.name);
|
// String dropSql = "alter table " + tableName + " drop(";
|
// for (int i = 0; i < removeAbList.size(); i++) {
|
// dropSql += removeAbList.get(i);
|
// if (i < removeAbList.size() - 1) {
|
// dropSql += ",";
|
// }
|
// }
|
// dropSql += ")";
|
// List<String> sqlList = new ArrayList<String>();
|
// sqlList.add(dropSql);
|
// // 更新btmItem的子类型表
|
// String[] childrenNames = BtmClient.getService().getChildrenNames(btmItem.name);
|
// for (String name : childrenNames) {
|
// String tableName_ = OmdTools.getBTMTableName(name);
|
// String sql_ = dropSql.replace(tableName, tableName_);
|
// sqlList.add(sql_);
|
// }
|
// boolean dropFlag = DDLToolClient.getService()
|
// .batchExecuteUpdateOracle(sqlList.toArray(new String[0]));
|
// if (!dropFlag) {
|
// JOptionPane.showMessageDialog(getInstance(), "删除业务类型Table列失败", "修改Table失败",
|
// JOptionPane.INFORMATION_MESSAGE);
|
// return;
|
// } else {
|
// JOptionPane.showMessageDialog(getInstance(), "删除业务类型Table列成功", "修改Table成功",
|
// JOptionPane.INFORMATION_MESSAGE);
|
// }
|
// }
|
// // 没有不可删除的列,删除removeAbList中所有列
|
// } else {
|
// String tableName = OmdTools.getBTMTableName(btmItem.name);
|
// String dropSql = "alter table " + tableName + " drop(";
|
// for (int i = 0; i < removeAbList.size(); i++) {
|
// dropSql += removeAbList.get(i);
|
// if (i < removeAbList.size() - 1) {
|
// dropSql += ",";
|
// }
|
// }
|
// dropSql += ")";
|
// List<String> sqlList = new ArrayList<String>();
|
// sqlList.add(dropSql);
|
// // 更新btmItem的子类型表
|
// String[] childrenNames = BtmClient.getService().getChildrenNames(btmItem.name);
|
// for (String name : childrenNames) {
|
// String tableName_ = OmdTools.getBTMTableName(name);
|
// String sql_ = dropSql.replace(tableName, tableName_);
|
// sqlList.add(sql_);
|
// }
|
// // org.hibernate.Session session = HibernateSessionFactory.getSession();
|
// // Transaction t = session.beginTransaction();
|
//
|
// boolean dropFlag = DDLToolClient.getService()
|
// .batchExecuteUpdateOracle(sqlList.toArray(new String[0]));
|
// if (!dropFlag) {
|
// JOptionPane.showMessageDialog(getInstance(), "删除业务类型Table列失败", "修改Table失败",
|
// JOptionPane.INFORMATION_MESSAGE);
|
// return;
|
// } else {
|
// JOptionPane.showMessageDialog(getInstance(), "删除业务类型Table列成功", "修改Table成功",
|
// JOptionPane.INFORMATION_MESSAGE);
|
// }
|
// }
|
// }
|
boolean updateFlag = BtmClient.getService().updateBtmItem(btmItem);
|
if (updateFlag) {
|
JOptionPane.showMessageDialog(getInstance(), "修改业务类型成功", "修改成功", JOptionPane.INFORMATION_MESSAGE);
|
initBtmTree();
|
btmTree.updateUI();
|
updateApTable();
|
flag = 0;
|
} else {
|
JOptionPane.showMessageDialog(getInstance(), "修改业务类型失败", "修改失败", JOptionPane.INFORMATION_MESSAGE);
|
return;
|
}
|
} catch (VCIError e1) {
|
e1.printStackTrace();
|
}
|
}
|
}
|
});
|
|
btnCancel.addActionListener(new ActionListener() {
|
|
@Override
|
public void actionPerformed(ActionEvent e) {
|
flag = 0;
|
nameList.clear();
|
removeAbList.clear();
|
|
DefaultMutableTreeNode seletionNode = (DefaultMutableTreeNode) btmTree.getLastSelectedPathComponent();
|
if (seletionNode != null) {
|
if (seletionNode.getUserObject() instanceof BtmItemWrapper) {
|
updateBtmInfo(((BtmItemWrapper) seletionNode.getUserObject()).btmItem);
|
} else {
|
updateBtmInfo(null);
|
}
|
} else {
|
updateBtmInfo(null);
|
}
|
}
|
});
|
// 增加属性项
|
btnAdd.addActionListener(new ActionListener() {
|
|
@Override
|
public void actionPerformed(ActionEvent e) {
|
ApSelectDialog dialog = new ApSelectDialog(nameList);
|
dialog.setVisible(true);
|
String addName;
|
if (dialog.getSelectedApNameList() == null) {
|
return;
|
}
|
for (int i = 0; i < dialog.getSelectedApNameList().size(); i++) {
|
addName = dialog.getSelectedApNameList().get(i);
|
nameList.add(addName);
|
nameMap.get("").add(addName);
|
removeAbList.remove(addName);
|
}
|
updateApTable();
|
}
|
});
|
|
// 移除属性项
|
btnRemove.addActionListener(new ActionListener() {
|
|
@Override
|
public void actionPerformed(ActionEvent e) {
|
int selectRows[] = apTable.getSelectedRows();
|
if (selectRows.length < 1) {
|
JOptionPane.showMessageDialog(getInstance(), "请选择要删除的属性", "没有选择属性", JOptionPane.WARNING_MESSAGE);
|
return;
|
}
|
for (int i = 0; i < selectRows.length; i++) {
|
String selectFName = (String) apTable.getValueAt(selectRows[i], 1);
|
if (!selectFName.equals("") && !selectFName.equals(tfName.getText())) {
|
JOptionPane.showMessageDialog(getInstance(), "不能删除父类属性", "不能删除", JOptionPane.WARNING_MESSAGE);
|
return;
|
}
|
String selectName = (String) apTable.getValueAt(selectRows[i], 0);
|
if (selectFName == null || selectFName.equals("")) {
|
nameMap.get("").remove(selectName);
|
} else {
|
nameMap.get(selectFName).remove(selectName);
|
}
|
// add by guo
|
String[] oldApNameArray = btmItem.apNameArray;
|
for (int j = 0; j < oldApNameArray.length; j++) {
|
if (selectName.equals(oldApNameArray[j])) {
|
removeAbList.add(selectName);
|
nameList.remove(selectName);
|
}
|
}
|
// removeAbList.add(selectName);
|
// nameList.remove(selectName);
|
}
|
// edit end liu 2015-07-14
|
updateApTable();
|
}
|
});
|
|
btnLCAdd.addActionListener(new ActionListener() {
|
|
@Override
|
public void actionPerformed(ActionEvent e) {
|
List<String> lcList = getLCList();
|
String lc = getLC();
|
if (lcList != null) {
|
if (!lc.equals("")) {
|
lcList.add(lc);
|
}
|
} else {
|
if (!lc.equals("")) {
|
lcList = new ArrayList<String>();
|
lcList.add(lc);
|
}
|
}
|
LCycleSelectDialog dialog = new LCycleSelectDialog(lcList);
|
dialog.setVisible(true);
|
List<String> selectNames = dialog.getSelectNames();
|
if (selectNames != null && selectNames.size() > 0) {
|
lcTable.setEditable(true);
|
int oldCount = lcTable.getRowCount();
|
lcTableModel.setRowCount(oldCount + selectNames.size());
|
for (int i = oldCount; i < lcTableModel.getRowCount(); i++) {
|
lcTable.setValueAt(selectNames.get(i - oldCount), i, 0);
|
}
|
lcTable.setEditable(false);
|
}
|
lcTable.updateUI();
|
}
|
});
|
|
btnLCRemove.addActionListener(new ActionListener() {
|
|
@Override
|
public void actionPerformed(ActionEvent e) {
|
removeSelRows();
|
}
|
});
|
|
btnDeleteData.addActionListener(new ActionListener() {
|
|
@Override
|
public void actionPerformed(ActionEvent e) {
|
// 删除所有对象数据
|
// truncate table platformlt_ebom
|
BtmItem[] allTypes = null;
|
LinkType[] allLinkType = null;
|
try {
|
allTypes = BtmClient.getService().getAllBtmItem("");
|
allLinkType = LinkTypeProvider.getInstance().getService().getLinkTypes();
|
} catch (Exception e1) {
|
e1.printStackTrace();
|
} catch (Throwable e1) {
|
e1.printStackTrace();
|
}
|
List<String> btNames = new ArrayList<String>();
|
List<String> ltNames = new ArrayList<String>();
|
|
if (allTypes != null) {
|
for (BtmItem bt : allTypes) {
|
btNames.add(bt.name);
|
}
|
}
|
if (allLinkType != null) {
|
for (LinkType lt : allLinkType) {
|
ltNames.add(lt.name);
|
}
|
}
|
if ((btNames.size() + ltNames.size()) < 1) {
|
JOptionPane.showMessageDialog(getInstance(), "没有需要删除的数据", "没有需要删除的数据",
|
JOptionPane.INFORMATION_MESSAGE);
|
return;
|
}
|
DeleteDataDialog dialog = new DeleteDataDialog(btNames, ltNames);
|
dialog.setVisible(true);
|
}
|
});
|
|
btnDeleteTypes.addActionListener(new ActionListener() {
|
|
@Override
|
public void actionPerformed(ActionEvent e) {
|
// 删除表以及类型
|
// drop table platformlt_ebom
|
BtmItem[] allTypes = null;
|
LinkType[] allLinkType = null;
|
try {
|
allTypes = BtmClient.getService().getAllBtmItem("");
|
allLinkType = LinkTypeProvider.getInstance().getService().getLinkTypes();
|
} catch (Exception e1) {
|
e1.printStackTrace();
|
} catch (Throwable e1) {
|
e1.printStackTrace();
|
}
|
List<BtmItem> bts = new ArrayList<BtmItem>();
|
List<LinkType> ltNames = new ArrayList<LinkType>();
|
|
if (allTypes != null) {
|
for (BtmItem bt : allTypes) {
|
bts.add(bt);
|
}
|
}
|
if (allLinkType != null) {
|
for (LinkType lt : allLinkType) {
|
ltNames.add(lt);
|
}
|
}
|
if ((bts.size() + ltNames.size()) < 1) {
|
JOptionPane.showMessageDialog(getInstance(), "没有需要删除的数据", "没有需要删除的数据",
|
JOptionPane.INFORMATION_MESSAGE);
|
return;
|
}
|
List<String> exceptBts = new ArrayList<String>();
|
exceptBts.add(FileObjectType.FILE_DATA_TABLE);
|
exceptBts.add("workitem");
|
DeleteTypeDialog dialog = new DeleteTypeDialog(bts, ltNames, exceptBts);
|
dialog.setVisible(true);
|
}
|
});
|
|
//btnXml2DB.addActionListener(new Xml2DBActionListener());
|
btnExp.addActionListener(new ExpActionListener());
|
btnImp.addActionListener(new ImpActionListener(this));
|
btnSetIndex.addActionListener(new SetIndexActionListener(btmTree));
|
|
// 添加取消创建、修改的事件相应
|
|
}
|
|
|
private void findInTree(String str) {
|
Object root = btmTree.getModel().getRoot();
|
TreePath treePath = new TreePath(root);
|
treePath = findInPath(treePath, str);
|
if (treePath != null) {
|
btmTree.setSelectionPath(treePath);
|
btmTree.scrollPathToVisible(treePath);
|
}
|
}
|
|
private TreePath findInPath(TreePath treePath, String str) {
|
Object object = treePath.getLastPathComponent();
|
if (object == null) {
|
return null;
|
}
|
|
String value = object.toString();
|
if (str.equals(value)) {
|
return treePath;
|
} else {
|
TreeModel model = btmTree.getModel();
|
int n = model.getChildCount(object);
|
for (int i = 0; i < n; i++) {
|
Object child = model.getChild(object, i);
|
TreePath path = treePath.pathByAddingChild(child);
|
|
path = findInPath(path, str);
|
if (path != null) {
|
return path;
|
}
|
}
|
return null;
|
}
|
}
|
|
|
public void initBtmTree() {
|
try {
|
btmArray = BtmClient.getService().getAllBtmItem("");
|
btmListMap = new HashMap<String, ArrayList<BtmItem>>();
|
BtmItem btmItem = null;
|
rootNode = (DefaultMutableTreeNode) btmTree.getModel().getRoot();
|
if (!rootNode.isLeaf()) {
|
rootNode.removeAllChildren();
|
}
|
for (int i = 0; i < btmArray.length; i++) {
|
btmItem = btmArray[i];
|
if (btmItem.fName.equals("")) {
|
rootNode.add(new DefaultMutableTreeNode(new BtmItemWrapper(btmItem)));
|
} else {
|
if (btmListMap.get(btmItem.fName) == null) {
|
ArrayList<BtmItem> btmList = new ArrayList<BtmItem>();
|
btmList.add(btmItem);
|
btmListMap.put(btmItem.fName, btmList);
|
} else {
|
btmListMap.get(btmItem.fName).add(btmItem);
|
}
|
}
|
}
|
// 也许这段可以加到上面的if中
|
for (Enumeration<DefaultMutableTreeNode> e = rootNode.children(); e.hasMoreElements();) {
|
DefaultMutableTreeNode node = e.nextElement();
|
if (node.isLeaf()) {
|
addBtmNodeToTree(node);
|
}
|
}
|
|
btmTree.expandPath(new TreePath(rootNode));
|
} catch (VCIError e) {
|
e.printStackTrace();
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
}
|
|
/**
|
* 由叶子节点去btmListMap中查找子节点
|
*
|
* @param node
|
*/
|
private void addBtmNodeToTree(DefaultMutableTreeNode node) {
|
BtmItem btmItem = ((BtmItemWrapper) node.getUserObject()).btmItem;
|
if (btmListMap.get(btmItem.name) == null) {
|
return;
|
} else {
|
ArrayList<BtmItem> btmList = null;
|
BtmItem btmItem_ = null;
|
DefaultMutableTreeNode node_ = null;
|
btmList = btmListMap.get(btmItem.name);
|
Collections.sort(btmList, new BTComparator());
|
for (int i = 0; i < btmList.size(); i++) {
|
btmItem_ = btmList.get(i);
|
node_ = new DefaultMutableTreeNode(new BtmItemWrapper(btmItem_));
|
node.add(node_);
|
addBtmNodeToTree(node_);
|
}
|
}
|
|
}
|
|
/**
|
* 获取选取节点的属性列表
|
*/
|
private void updateNameMap() {
|
// BtmAndApName[] btmAndApNameArray;
|
// BtmAndApName btmAndApName;
|
// ArrayList<String> nameList_;
|
nameList = new ArrayList<String>();
|
nameMap = new HashMap<String, List<String>>();
|
nameMap.put("", new ArrayList<String>());
|
if (selectedNodeName.equals("")) {
|
return;
|
}
|
|
String btmName = selectedNodeName;
|
try {
|
BtmItem bt = BtmClient.getService().getBtmItemByName(btmName);
|
|
nameMap.put(bt.name, Arrays.asList(bt.apNameArray));
|
} catch (VCIError e) {
|
e.printStackTrace();
|
}
|
}
|
|
private void updateApTable() {
|
if (nameMap.isEmpty() || nameMap == null) {
|
scrollPanel.setViewport(null);
|
} else {
|
apTable = new ApTableForBtm(nameMap);
|
scrollPanel.setViewportView(apTable);
|
}
|
}
|
|
/**
|
* 业务类型变化时,更新业务类型的信息
|
*
|
* @param btmItem
|
*/
|
private void updateBtmInfo(BtmItem btmItem) {
|
this.btmItem = btmItem;
|
// 浏览
|
if (flag == 0) {
|
this.statusChangeToFalse();
|
// tfName.setEditable(false);
|
// tfLabel.setEditable(false);
|
// tfImplClass.setEditable(false);
|
// tfFName.setEditable(false);
|
// taDescrip.setEditable(false);
|
// chbAbstract.setEnabled(false);
|
// chbRevInput.setEnabled(false);
|
// rdLevel0.setEnabled(false);
|
// rdLevel1.setEnabled(false);
|
// rdLevel2.setEnabled(false);
|
// rdVerABC.setEnabled(false);
|
// rdVer123.setEnabled(false);
|
// rdVer012.setEnabled(false);
|
// combDelimiter.setEnabled(false);
|
// btnRevRuleName.setVisible(false);
|
// btnFName.setEnabled(false);
|
// btnImage.setEnabled(false);
|
// btnRemove.setVisible(false);
|
// btnAdd.setVisible(false);
|
// btnOK.setVisible(false);
|
// btnCancel.setVisible(false);
|
// // 生命周期
|
// tfLCycle.setEditable(false);
|
// btnLCycle.setVisible(false);
|
// btnLCAdd.setVisible(false);
|
// btnLCRemove.setVisible(false);
|
} else if (flag == 1 || flag == 2) {
|
statusChangeToTrue();
|
|
// tfLabel.setEditable(true);
|
// tfImplClass.setEditable(true);
|
// tfFName.setEditable(false);
|
// chbAbstract.setEnabled(true);
|
// chbRevInput.setEnabled(true);
|
// taDescrip.setEditable(true);
|
// rdLevel0.setEnabled(true);
|
// rdLevel1.setEnabled(true);
|
// rdLevel2.setEnabled(true);
|
// rdVerABC.setEnabled(true);
|
// rdVer123.setEnabled(true);
|
// rdVer012.setEnabled(true);
|
// combDelimiter.setEnabled(true);
|
// btnRevRuleName.setVisible(true);
|
// btnImage.setEnabled(true);
|
// btnRemove.setVisible(true);
|
// btnAdd.setVisible(true);
|
// btnOK.setVisible(true);
|
// btnCancel.setVisible(true);
|
// // 生命周期
|
// tfLCycle.setEditable(true);
|
// btnLCycle.setVisible(true);
|
// btnLCAdd.setVisible(true);
|
// btnLCRemove.setVisible(true);
|
}
|
if (btmItem == null) {
|
tfName.setText("");
|
chbAbstract.setSelected(false);
|
chbRevInput.setSelected(false);
|
tfLabel.setText("");
|
tfImplClass.setText("");
|
tfFName.setText("");
|
taDescrip.setText("");
|
rdLevel0.setSelected(false);
|
rdLevel1.setSelected(false);
|
rdLevel2.setSelected(true);
|
tfRevRuleName.setText("");
|
combDelimiter.setSelectedItem(null);
|
rdVer123.setSelected(true);
|
rdVerABC.setSelected(false);
|
rdVer012.setSelected(false);
|
lblImage.setIcon(null);
|
// 生命周期
|
tfLCycle.setText("");
|
lcTable.setEditable(true);
|
lcTableModel.setRowCount(0);
|
lcTable.setEditable(false);
|
} else {
|
tfName.setText(btmItem.name);
|
if (btmItem.isAbstract) {
|
chbAbstract.setSelected(true);
|
} else {
|
chbAbstract.setSelected(false);
|
}
|
tfLabel.setText(btmItem.label);
|
tfImplClass.setText(btmItem.implClass);
|
tfFName.setText(btmItem.fName);
|
taDescrip.setText(btmItem.description);
|
if (btmItem.revLevel == 0) {
|
rdLevel0.setSelected(true);
|
} else if (btmItem.revLevel == 1) {
|
rdLevel1.setSelected(true);
|
} else if (btmItem.revLevel == 2) {
|
rdLevel2.setSelected(true);
|
}
|
if (btmItem.revInput) {
|
chbRevInput.setSelected(true);
|
} else {
|
chbRevInput.setSelected(false);
|
}
|
tfRevRuleName.setText(btmItem.revRuleName);
|
combDelimiter.setSelectedItem(btmItem.delimiter);
|
if (btmItem.verRuleName == 0) {
|
rdVer123.setSelected(true);
|
} else if (btmItem.verRuleName == 1) {
|
rdVerABC.setSelected(true);
|
} else if (btmItem.verRuleName == 2) {
|
rdVer012.setSelected(true);
|
}
|
|
if (!basePathISURL()) {
|
imageURL = btmItem.imageName;
|
} else if (imageURL == null || imageURL.equals("")) {
|
btmItem.imageName = imageURL;
|
} else {
|
imageURL = LogonApplication.urlBasePath + btmItem.imageName;
|
}
|
|
// 生命周期
|
tfLCycle.setText(btmItem.lifeCycle);
|
lcTable.setEditable(true);
|
String[] lifeCycles = btmItem.lifeCycles;
|
lcTableModel.setRowCount(lifeCycles.length);
|
for (int i = 0; i < lifeCycles.length; i++) {
|
lcTable.setValueAt(lifeCycles[i], i, 0);
|
}
|
lcTable.setEditable(false);
|
}
|
setVisibleForRev();
|
updateNameMap();
|
updateApTable();
|
|
}
|
|
/**
|
* 有实例:true 无实例:false
|
*
|
* @return
|
*/
|
private boolean hasInstance(String btmName) {
|
//String tableName = OmdTools.getBTMTableName(btmName);
|
//boolean flag = DDLToolClient.getService().hasInstanceOralce(tableName);
|
boolean flag = false;
|
try {
|
flag = ServiceProvider.getOMDService().getBTMService().hasData(btmName);
|
} catch (VCIError e) {
|
// TODO Auto-generated catch block
|
e.printStackTrace();
|
}
|
return flag;
|
}
|
|
private boolean checkName() {
|
if (tfName.getText().equals("")) {
|
JOptionPane.showMessageDialog(this, "请输入业务类型名", "业务类型名错误", JOptionPane.ERROR_MESSAGE);
|
statusChangeToTrue();
|
return false;
|
}
|
|
String name = tfName.getText();
|
if (!name.matches("[a-z A-Z]*")) {
|
JOptionPane.showMessageDialog(this, "业务类型名只能为英文字母", "业务类型名错误", JOptionPane.ERROR_MESSAGE);
|
statusChangeToTrue();
|
return false;
|
}
|
|
int maxLength = 0;
|
try {
|
maxLength = ServiceProvider.getOMDService().getBTMService().getBTNameMaxLength();
|
} catch (VCIError e) {
|
// TODO Auto-generated catch block
|
e.printStackTrace();
|
return false;
|
}
|
if (name.length() > maxLength) {
|
JOptionPane.showMessageDialog(this, "业务类型名长度不能超过" + maxLength, "业务类型名错误", JOptionPane.ERROR_MESSAGE);
|
statusChangeToTrue();
|
return false;
|
}
|
try {
|
if (BtmClient.getService().checkRowIsExists(tfName.getText())) {
|
JOptionPane.showMessageDialog(this, "业务类型名已经存在", "业务类型名错误", JOptionPane.ERROR_MESSAGE);
|
statusChangeToTrue();
|
return false;
|
}
|
} catch (VCIError e) {
|
e.printStackTrace();
|
}
|
return true;
|
}
|
|
/**
|
* 必须选择生命周期
|
*
|
* @return
|
*/
|
private boolean checkLifeCycle() {
|
if (tfLCycle.getText().equals("")) {
|
JOptionPane.showMessageDialog(this, "请选择生命周期", "提示", JOptionPane.WARNING_MESSAGE);
|
statusChangeToTrue();
|
return false;
|
}
|
return true;
|
}
|
|
/**
|
* 选择一级版本:必须选择或手工输入版本号规则; 选择二级版本:必须选择或手工输入版本号规则, (版次号已经默认选择).
|
*
|
* @return
|
*/
|
private boolean checkVersionInfo() {
|
if (rdLevel1.isSelected() || rdLevel2.isSelected()) {
|
if (tfRevRuleName.getText().equals("") && !chbRevInput.isSelected()) {
|
JOptionPane.showMessageDialog(this, "请设置版本号规则", "提示", JOptionPane.WARNING_MESSAGE);
|
statusChangeToTrue();
|
return false;
|
}
|
}
|
return true;
|
}
|
|
/**
|
* 版本机制修改: 仅允许类型从"不可修订"变更至"一级版本管理机制","二级版本管理机制进行调整"; "一级版本管理机制"变更至"二级版本管理机制";
|
* 两种方式.
|
*
|
* @return
|
*/
|
private boolean checkRevLevel() {
|
if (btmItem.revLevel == 1 && rdLevel0.isSelected()) {
|
JOptionPane.showMessageDialog(this, "不能从一级变为不可修订", "版本变更错误", JOptionPane.WARNING_MESSAGE);
|
statusChangeToTrue();
|
rdLevel1.setSelected(true);
|
return false;
|
}
|
|
if (btmItem.revLevel == 2 && (rdLevel0.isSelected() || rdLevel1.isSelected())) {
|
JOptionPane.showMessageDialog(this, "不能从二级变为一级或不可修订", "版本变更错误", JOptionPane.WARNING_MESSAGE);
|
statusChangeToTrue();
|
rdLevel2.setSelected(true);
|
return false;
|
}
|
return true;
|
}
|
|
private void updateImage(boolean isTomcatPath) {
|
lblImage.removeAll();
|
if (imageURL == null || imageURL.equals("")) {
|
lblImage.setIcon(null);
|
return;
|
}
|
// 本地路径条件下
|
if (!isTomcatPath) {
|
// lblImage.setIcon(new ImageIcon(imageURL));
|
ImageIcon icon = new BundleImage().createImageIcon(imageURL);
|
lblImage.setIcon(icon);
|
return;
|
}
|
// URL条件下
|
URL url = null;
|
try {
|
url = new URL(imageURL);
|
} catch (MalformedURLException e) {
|
e.printStackTrace();
|
}
|
if (url != null) {
|
lblImage.setIcon(new ImageIcon(url));
|
}
|
}
|
|
/**
|
* 获取修改业务类型时 增加的属性, 以便将这些属性增加到该业务类型表的属性列中
|
*
|
* @param oldNames
|
* @param names
|
* @return
|
*/
|
private ArrayList<String> getAddedApList(String[] oldNames, String[] names) {
|
ArrayList<String> oldNameList = BtmTool.getInstance().convertArrayToList(oldNames);
|
ArrayList<String> newNameList = BtmTool.getInstance().convertArrayToList(names);
|
ArrayList<String> addedApList = new ArrayList<String>();
|
|
for (Iterator<String> iterator = newNameList.iterator(); iterator.hasNext();) {
|
String newName = iterator.next();
|
if (!oldNameList.contains(newName)) {
|
addedApList.add(newName);
|
}
|
}
|
return addedApList;
|
}
|
|
/**
|
* 根据版本号规则设置显示
|
*/
|
private void setVisibleForRev() {
|
if (rdLevel0.isSelected()) {
|
lblRevRuleName.setVisible(false);
|
tfRevRuleName.setVisible(false);
|
btnRevRuleName.setVisible(false);
|
chbRevInput.setVisible(false);
|
lblDelimiter.setVisible(false);
|
combDelimiter.setVisible(false);
|
lblVer.setVisible(false);
|
rdVer123.setVisible(false);
|
rdVerABC.setVisible(false);
|
rdVer012.setVisible(false);
|
} else if (rdLevel1.isSelected()) {
|
lblRevRuleName.setVisible(true);
|
tfRevRuleName.setVisible(true);
|
btnRevRuleName.setVisible(true);
|
chbRevInput.setVisible(true);
|
lblDelimiter.setVisible(true);
|
combDelimiter.setVisible(true);
|
lblVer.setVisible(false);
|
rdVer123.setVisible(false);
|
rdVerABC.setVisible(false);
|
rdVer012.setVisible(false);
|
} else if (rdLevel2.isSelected()) {
|
lblRevRuleName.setVisible(true);
|
tfRevRuleName.setVisible(true);
|
btnRevRuleName.setVisible(true);
|
chbRevInput.setVisible(true);
|
lblDelimiter.setVisible(true);
|
combDelimiter.setVisible(true);
|
lblVer.setVisible(true);
|
rdVer123.setVisible(true);
|
rdVerABC.setVisible(true);
|
rdVer012.setVisible(true);
|
}
|
}
|
|
/**
|
* 判断urlBasePath是否是URL
|
*
|
* @return
|
*/
|
public boolean basePathISURL() {
|
String urlBasePath = LogonApplication.urlBasePath;
|
if (urlBasePath == null || urlBasePath.equals("") || urlBasePath.equals(".")) {
|
return false;
|
} else {
|
return true;
|
}
|
}
|
|
/**
|
* 返回备选生命周期列表
|
*
|
* @return
|
*/
|
private List<String> getLCList() {
|
if (lcTable == null) {
|
return null;
|
}
|
int rowCount = lcTable.getRowCount();
|
if (rowCount < 1) {
|
return null;
|
}
|
List<String> list = new ArrayList<String>();
|
for (int i = 0; i < rowCount; i++) {
|
list.add(String.valueOf(lcTable.getValueAt(i, 0)));
|
}
|
return list;
|
}
|
|
/**
|
* 返回生命周期
|
*
|
* @return
|
*/
|
private String getLC() {
|
return tfLCycle.getText();
|
}
|
|
/**
|
* 移除选择的记录
|
*/
|
private void removeSelRows() {
|
List<String> list = new ArrayList<String>();
|
int[] sRows = lcTable.getSelectedRows();
|
List<?> sList = Arrays.asList(sRows);
|
for (int i = 0; i < lcTable.getRowCount(); i++) {
|
if (!sList.contains(i)) {
|
list.add((String) lcTable.getValueAt(i, 0));
|
}
|
}
|
lcTable.setEditable(true);
|
lcTableModel.setRowCount(list.size());
|
for (int i = 0; i < list.size(); i++) {
|
lcTable.setValueAt(list.get(i), i, 0);
|
}
|
lcTable.setEditable(false);
|
lcTable.updateUI();
|
}
|
|
public List<BtmItem> getSelectedBtms() {
|
TreePath[] selectionPaths = btmTree.getSelectionPaths();
|
// 未选中, 返回
|
if (selectionPaths == null || selectionPaths.length == 0) {
|
return null;
|
}
|
// 选中根节点, 返回
|
if (selectionPaths.length == 1 && !(((DefaultMutableTreeNode) selectionPaths[0].getLastPathComponent())
|
.getUserObject() instanceof BtmItemWrapper)) {
|
return null;
|
}
|
List<BtmItem> list = new ArrayList<BtmItem>();
|
for (TreePath path : selectionPaths) {
|
DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
|
Object obj = node.getUserObject();
|
if (obj instanceof BtmItemWrapper) {
|
list.add(((BtmItemWrapper) obj).btmItem);
|
}
|
}
|
return list;
|
}
|
|
// add by guo
|
public void statusChangeToTrue() {
|
if (flag == 1) {
|
tfName.setEditable(true);
|
// lblFName.setEditable(false);
|
tfFName.setEditable(false);
|
btnFName.setEnabled(false);
|
} else {
|
tfName.setEditable(false);
|
// lblFName.setEditable(true);
|
tfFName.setEditable(true);
|
btnFName.setEnabled(true);
|
}
|
tfLabel.setEditable(true);
|
tfImplClass.setEditable(true);
|
taDescrip.setEditable(true);
|
btnImage.setEnabled(true);
|
btnLCAdd.setVisible(true);
|
btnLCRemove.setVisible(true);
|
btnFName.setEnabled(true);
|
rdLevel0.setEnabled(true);
|
rdLevel1.setEnabled(true);
|
rdLevel2.setEnabled(true);
|
btnRevRuleName.setEnabled(true);
|
tfRevRuleName.setEditable(true);
|
chbRevInput.setEnabled(true);
|
combDelimiter.setEnabled(true);
|
rdVer012.setEnabled(true);
|
rdVer123.setEnabled(true);
|
rdVerABC.setEnabled(true);
|
btnLCycle.setVisible(true);
|
tfLCycle.setEditable(true);
|
lcTable.setEditable(true);
|
btnAdd.setEnabled(true);
|
btnRemove.setEnabled(true);
|
btnOK.setVisible(true);
|
btnCancel.setVisible(true);
|
}
|
|
// add by guo
|
public void statusChangeToFalse() {
|
tfName.setEditable(false);
|
tfFName.setEditable(false);
|
btnFName.setEnabled(false);
|
tfLabel.setEditable(false);
|
tfImplClass.setEditable(false);
|
taDescrip.setEditable(false);
|
btnImage.setEnabled(false);
|
btnLCAdd.setVisible(false);
|
btnLCRemove.setVisible(false);
|
btnFName.setEnabled(false);
|
rdLevel0.setEnabled(false);
|
rdLevel1.setEnabled(false);
|
rdLevel2.setEnabled(false);
|
btnRevRuleName.setEnabled(false);
|
tfRevRuleName.setEditable(false);
|
chbRevInput.setEnabled(false);
|
combDelimiter.setEnabled(false);
|
rdVer012.setEnabled(false);
|
rdVer123.setEnabled(false);
|
rdVerABC.setEnabled(false);
|
btnLCycle.setVisible(false);
|
tfLCycle.setEditable(false);
|
lcTable.setEditable(false);
|
btnAdd.setEnabled(false);
|
btnRemove.setEnabled(false);
|
btnOK.setVisible(false);
|
btnCancel.setVisible(false);
|
}
|
|
// add by caill
|
public void sel() {
|
String textValue = textField2.getText().trim();
|
// BtmAndApName[] btmAndApNameArray;
|
// BtmAndApName btmAndApName;
|
ArrayList<String> nameList_;
|
nameList = new ArrayList<String>();
|
nameMap = new HashMap<String, List<String>>();
|
nameMap.put("", new ArrayList<String>());
|
if (selectedNodeName.equals("")) {
|
return;
|
}
|
String btmName = selectedNodeName;
|
try {
|
// btmAndApNameArray = BtmClient.getService().getBtmAndApNameArray(btmName);
|
// for(int i = 0; i < btmAndApNameArray.length; i++){
|
// btmAndApName = btmAndApNameArray[i];
|
// nameList_ = new ArrayList<String>();
|
// //对查询框中是否有值做了判断
|
// if(textValue.equals("")){
|
// for(int k = 0; k < btmAndApName.apName.length; k++){
|
// nameList_.add(btmAndApName.apName[k]);
|
// nameList.add(btmAndApName.apName[k]);
|
// }
|
// }else{
|
// for(int k = 0; k < btmAndApName.apName.length; k++){
|
// if(btmAndApName.apName[k].contains(textValue)){
|
// nameList_.add(btmAndApName.apName[k]);
|
// nameList.add(btmAndApName.apName[k]);
|
// }
|
// }
|
// }
|
// nameMap.put(btmAndApName.btmName, nameList_);
|
// }
|
BtmItem bt = BtmClient.getService().getBtmItemByName(btmName);
|
if (textValue.equals("")) {
|
nameMap.put(bt.name, Arrays.asList(bt.apNameArray));
|
} else {
|
nameList_ = new ArrayList<String>();
|
for (int i = 0; i < bt.apNameArray.length; i++) {
|
nameList_.add(bt.apNameArray[i]);
|
nameList.add(bt.apNameArray[i]);
|
}
|
nameMap.put(bt.name, nameList_);
|
}
|
} catch (VCIError en) {
|
en.printStackTrace();
|
}
|
updateApTable();
|
}
|
}
|