package com.vci.client.framework.rightConfig.functiontree; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.LinkedList; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JFileChooser; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTextField; import javax.swing.text.AttributeSet; import javax.swing.text.BadLocationException; import javax.swing.text.PlainDocument; import javax.swing.tree.TreePath; import org.apache.poi.hssf.usermodel.HSSFFont; import org.apache.poi.ss.usermodel.CellStyle; import org.apache.poi.ss.usermodel.Workbook; import com.vci.client.ClientSession; import com.vci.client.LogonApplication; import com.vci.client.common.IconSelectDialog; import com.vci.client.common.TransmitTreeObject; import com.vci.client.framework.delegate.FunctionClientDelegate; import com.vci.client.framework.rightConfig.modelConfig.ModuleConfigMainPanel; import com.vci.client.framework.rightConfig.object.FunctionObject; import com.vci.client.omd.btm.ui.BtmPanel; import com.vci.client.ui.exception.VCIException; import com.vci.client.ui.image.BundleImage; import com.vci.client.ui.locale.LocaleDisplay; import com.vci.client.ui.process.QANProcessBar; import com.vci.client.ui.process.QANProcessBarFrame; import com.vci.client.ui.swing.VCIOptionPane; import com.vci.client.ui.swing.VCISwingUtil; import com.vci.client.ui.swing.components.VCIJIntegerTextField; import com.vci.client.ui.swing.components.VCIJOptionPane; import com.vci.client.ui.swing.components.VCIJTextArea; import com.vci.client.ui.swing.components.VCIJTextField; import com.vci.client.ui.tree.VCIBaseTreeModel; import com.vci.client.ui.tree.VCIBaseTreeNode; import com.vci.client.ui.util.UIHelper; import com.vci.client.utils.excel.ExcelCellStyleSettingCallback; import com.vci.client.utils.excel.ExcelFileOperation; import com.vci.client.utils.excel.WorkboolStyleSetting; import com.vci.corba.common.VCIError; import com.vci.mw.ClientContextVariable; /** *
Title:
*Description: 创建模块界面
*Copyright: Copyright {c} 2011
*Company: VCI
* @author xf * @time 2012-05-14 * @version 1.0 */ public class ModelManagementPanel extends JPanel { private static final long serialVersionUID = 586924423L; private TransmitTreeObject transmitTreeObject = null; //模块对象 private final FunctionClientDelegate modelDelegate = new FunctionClientDelegate(LogonApplication.getUserEntityObject()); /** * 标题 */ private final JLabel titleLab = new JLabel(LocaleDisplay.getI18nString("rmip.framework.systemFunctionTree.title", "RMIPFramework", getLocale())); /** * 模块名称 */ private final JLabel modelNameLab = new JLabel(LocaleDisplay.getI18nString("rmip.framework.systemFunctionTree.modelManagment.modelName", "RMIPFramework", getLocale())); private final VCIJTextField modelNameTxt = new VCIJTextField(true); /** * 模块别名 */ private final JLabel aliasNameLbl = new JLabel("模块别名:"); private final VCIJTextField aliasTxt = new VCIJTextField(true); private final JLabel prompLbl = new JLabel("(*模块别名用来记录日志用)"); /** * B/S标识 */ private final JLabel bsSystemLab = new JLabel("B/S:"); private final VCIJTextArea bsTxt = new VCIJTextArea(false); /** * C/S标识 */ private final JLabel csSystemLab = new JLabel("C/S:"); private final VCIJTextArea csTxt = new VCIJTextArea(false); /** * .NET标识 */ private final JLabel dotNetSystemLab = new JLabel(".NET:"); private final VCIJTextArea dotNetTxt = new VCIJTextArea(false); /** * C/S标识 */ private final JLabel mobileSystemLab = new JLabel("Mobile:"); private final VCIJTextArea mobileTxt = new VCIJTextArea(false); /** * 序号 */ private final JLabel sequenceLab = new JLabel("序号"); private final VCIJIntegerTextField sequenceTxt = new VCIJIntegerTextField(""); /** * 编号 */ private final JLabel moduleNoLab = new JLabel("编号"); private final VCIJIntegerTextField moduleNoTxt = new VCIJIntegerTextField(""); /** * 简图 */ private final JLabel imageLab = new JLabel("简图"); private final VCIJTextField imageTxt = new VCIJTextField(false); private final JLabel imageConentLab = new JLabel(); private final JButton imageButton = new JButton("选择图标"); /** * 描述 */ private final JLabel descriptionLabel = new JLabel(LocaleDisplay.getI18nString("rmip.framework.systemFunctionTree.modelManagment.description", "RMIPFramework", getLocale())); private final VCIJTextArea descriptionText = new VCIJTextArea(); /** * 是否有效标识 */ private final JCheckBox isValid = new JCheckBox(LocaleDisplay.getI18nString("rmip.framework.systemFunctionTree.modelManagment.isValid", "RMIPFramework", getLocale())); private final JTextField textField1 = new JTextField(); private final JTextField textField2 = new JTextField(); //操作按钮 private final JButton addButton = new JButton(); private final JButton modifyButton = new JButton(); private final JButton deleteButton = new JButton(); private final JButton addOperateButton = new JButton(); private final JButton importButton = new JButton("导入"); private final JButton exportButton = new JButton("导出"); private final JButton exportSqlButton = new JButton("导出sql"); //private final JButton viewI18nButton = new JButton("查看国际化字典"); /** * 删除非系统模块 */ private final JButton delNonSysBtn = new JButton(); /** * 删除业务模块 */ private final JButton delBusiBtn = new JButton(); // 控件的坐标位置变量 private int x = 10; private int y = 20; private int width = 50; private int height = 25; //父对象 private FunOperateImportDialog ownerDialog = null; private ArrayListDescription: 右边面板的初始化
* *@author ligang *@time 2011-6-2 *@return void */ private void init() { titleLab.setIcon(new BundleImage().createImageIcon("specialCharacter.gif")); titleLab.setBounds(0, 0, 30, 25); JPanel bottomPanel = new JPanel(); JPanel middlePanel = new JPanel(); initBottom(bottomPanel); initMiddleV2(middlePanel); //按钮事件 initAction(); //自动生成模块编号 //initModuleNo(); this.setLayout(new BorderLayout()); //布局面板的上部,中部和下部 this.add(titleLab, BorderLayout.NORTH); this.add(middlePanel, BorderLayout.CENTER); this.add(bottomPanel, BorderLayout.SOUTH); } private void initMiddleV2(JPanel middlePanel){ textField1.setPreferredSize(new Dimension(63,2)); textField2.setPreferredSize(new Dimension(63,2)); int gridx = 0; int gridy = 0; int padxy = 3; // 用于初始批显示数据 // initMiddle(new JPanel()); JPanel panel = new JPanel(new GridBagLayout()); // 模块名称 gridx = 0; gridy = 0; panel.add(modelNameLab, getGBC(gridx++, gridy, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, padxy)); panel.add(modelNameTxt, getGBC(gridx++, gridy, 1, 1, 2.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, padxy)); // 别名 gridx = 0; gridy += 1; prompLbl.setForeground(Color.RED); panel.add(aliasNameLbl, getGBC(gridx++, gridy, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, padxy)); panel.add(aliasTxt, getGBC(gridx++, gridy, 1, 1, 2.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, padxy)); panel.add(prompLbl, getGBC(gridx++, gridy, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, padxy)); // B/S JScrollPane jspBSText = new JScrollPane(bsTxt); gridx = 0; gridy += 1; panel.add(bsSystemLab, getGBC(gridx++, gridy, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, padxy)); panel.add(jspBSText, getGBC(gridx++, gridy, 1, 1, 2.0, 2.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, padxy)); // C/S JScrollPane jspCSText = new JScrollPane(csTxt); gridx = 0; gridy += 1; panel.add(csSystemLab, getGBC(gridx++, gridy, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, padxy)); panel.add(jspCSText, getGBC(gridx++, gridy, 1, 1, 2.0, 2.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, padxy)); //.NET JScrollPane jspNotNet = new JScrollPane(dotNetTxt); gridx = 0; gridy += 1; panel.add(dotNetSystemLab, getGBC(gridx++, gridy, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, padxy)); panel.add(jspNotNet, getGBC(gridx++, gridy, 1, 1, 2.0, 2.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, padxy)); //Moblie JScrollPane jspMobile = new JScrollPane(mobileTxt); gridx = 0; gridy += 1; panel.add(mobileSystemLab, getGBC(gridx++, gridy, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, padxy)); panel.add(jspMobile, getGBC(gridx++, gridy, 1, 1, 2.0, 2.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, padxy)); // 序号 gridx = 0; gridy += 2; sequenceTxt.setRequired(true); panel.add(sequenceLab, getGBC(gridx++, gridy, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, padxy)); panel.add(sequenceTxt, getGBC(gridx++, gridy, 1, 1, 2.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, padxy)); JLabel lblSeqInfo = new JLabel("" + "(* 数字,描述该模块在其父模块下的显示顺序)"); lblSeqInfo.setForeground(Color.red); panel.add(lblSeqInfo, getGBC(gridx++, gridy, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, padxy)); // 编号 // gridx = 0; gridy += 1; // moduleNoTxt.setRequired(true); // panel.add(moduleNoLab, getGBC(gridx++, gridy, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, padxy)); // panel.add(moduleNoTxt, getGBC(gridx++, gridy, 1, 1, 2.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, padxy)); // JLabel lblMNInfo = new JLabel("" + // "(* 数字,描述该模块唯一的数字编号)"); // lblMNInfo.setForeground(Color.red); // panel.add(lblMNInfo, getGBC(gridx++, gridy, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, padxy)); // 简图 imageTxt.setEditable(false); gridx = 0; gridy += 1; panel.add(imageLab, getGBC(gridx++, gridy, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, padxy)); panel.add(imageTxt, getGBC(gridx++, gridy, 1, 1, 2.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, padxy)); panel.add(imageButton, getGBC(gridx++, gridy, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, padxy)); // 描述 gridx = 0; gridy += 1; panel.add(descriptionLabel, getGBC(gridx++, gridy, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, padxy)); bsTxt.setLineWrap(true); bsTxt.setRows(3); bsTxt.setColumns(10); bsTxt.setDocument(getNotIncludeLineDoc()); csTxt.setLineWrap(true); csTxt.setRows(3); csTxt.setColumns(10); csTxt.setDocument(getNotIncludeLineDoc()); dotNetTxt.setLineWrap(true); dotNetTxt.setRows(3); dotNetTxt.setColumns(10); dotNetTxt.setDocument(getNotIncludeLineDoc()); mobileTxt.setLineWrap(true); mobileTxt.setRows(3); mobileTxt.setColumns(10); mobileTxt.setDocument(getNotIncludeLineDoc()); descriptionText.setLineWrap(true); descriptionText.setRows(3); descriptionText.setColumns(10); JScrollPane jspDesc = new JScrollPane(descriptionText); panel.add(jspDesc, getGBC(gridx++, gridy, 1, 1, 2.0, 2.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, padxy)); gridx += 3; // 是否生效 gridx = 1; gridy += 1; panel.add(isValid, getGBC(gridx++, gridy, 1, 2, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, padxy)); JLabel lblValidInfo = new JLabel("" + "(* 不生效(不√选)时,该模块在功能模块授权里不显示)"); lblValidInfo.setForeground(Color.red); panel.add(lblValidInfo, getGBC(gridx++, gridy, 1, 1, 0.5, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, padxy)); gridx = 0; gridy += 1; panel.add(new JLabel(""), getGBC(gridx++, gridy, 3, 10, 10.0, 10.0, GridBagConstraints.NORTHEAST, GridBagConstraints.BOTH, padxy)); middlePanel.setLayout(new BorderLayout()); middlePanel.add(textField1, BorderLayout.NORTH); middlePanel.add(panel, BorderLayout.CENTER); middlePanel.add(textField2, BorderLayout.SOUTH); } private javax.swing.text.Document getNotIncludeLineDoc(){ javax.swing.text.Document res = new PlainDocument(){ @Override public void insertString(int offs, String str, AttributeSet a) throws BadLocationException { if (str == null) { return; } LinkedListDescription: 面板中部的布局
* *@author ligang *@time 2011-6-2 *@return void * @param middlePanel */ private void initMiddle(JPanel middlePanel) { JPanel panel = new JPanel(); panel.setPreferredSize(new Dimension(600,600)); panel.setLayout(null); textField1.setPreferredSize(new Dimension(63,2)); textField2.setPreferredSize(new Dimension(63,2)); //第一行 x = 30; y = 30; width = 70; height = 25; modelNameLab.setText(LocaleDisplay.getI18nString("rmip.framework.systemFunctionTree.modelManagment.modelName", "RMIPFramework", getLocale())); modelNameLab.setBounds(x, y, width, height);//模块名称 x += modelNameLab.getBounds().width ; y = 30; width = 600;height = 25; modelNameTxt.setBounds(x, y, width, height);//模块内容 //第二行 x = 30; y = 70; width = 70; height = 25; aliasNameLbl.setText("模块别名:"); aliasNameLbl.setBounds(x, y, width, height);//别名 x += aliasNameLbl.getBounds().width ; y = 70; width = 600;height = 25; aliasTxt.setBounds(x, y, width, height);//模块别名 x += aliasTxt.getBounds().width + 5 ; y = 70; width = 300;height = 25; //第三行 x = 30;y = 110;width = 70;height = 25; bsSystemLab.setText("B/S:"); bsSystemLab.setBounds(x, y, width, height);//B/S x += bsSystemLab.getBounds().width ; y = 110; width=600;height=25; bsTxt.setBounds(x, y, width, height); //第四行 x = 30;y = 150;width = 70;height = 25; csSystemLab.setText("C/S:"); csSystemLab.setBounds(x, y, width, height);//C/S x += csSystemLab.getBounds().width ; y = 150; width=600;height=25; csTxt.setBounds(x, y, width, height); //第五行 x = 30;y = 190;width = 70;height = 25; sequenceLab.setText("序号:"); sequenceLab.setBounds(x, y, width, height);//序号 x += sequenceLab.getBounds().width;y = 190; width = 600;height = 25; sequenceTxt.setBounds(x, y, width, height); //第六行 // x = 30;y = 230;width = 70;height = 25; // moduleNoLab.setText("编号:"); // moduleNoLab.setBounds(x, y, width, height);//编号 // // x += moduleNoLab.getBounds().width;y = 230; width = 600;height = 25; // moduleNoTxt.setBounds(x, y, width, height); //第七行 x = 30; y = 270; width = 70; height = 25; imageLab.setBounds(x, y, width, height); x += imageLab.getBounds().width; y = 270;width = 150; height = 25; imageTxt.setBounds(x, y, width, height); x += imageTxt.getBounds().width+5; y = 270;width = 25; height = 25; imageConentLab.setBounds(x, y, width, height); x += imageConentLab.getBounds().width; y = 270; width = 120; height = 25; imageButton.setBounds(x, y, width, height); //第八行 x = 30;y = 310;width = 70;height = 25; descriptionLabel.setText(LocaleDisplay.getI18nString("rmip.framework.systemFunctionTree.modelManagment.description", "RMIPFramework", getLocale())); descriptionLabel.setBounds(x,y,width,height);//描述 x += descriptionLabel.getBounds().width ; y = 310; width=600;height=130; JScrollPane jsDescription=new JScrollPane(); descriptionText.setLineWrap(true); jsDescription.setViewportView(descriptionText); jsDescription.setBounds(x, y, width, height); //是否有效 x = 30; y += jsDescription.getBounds().getHeight()+15; width = 80; height = 25; isValid.setSelected(true); isValid.setBounds(x, y, width, height); panel.add(modelNameLab); panel.add(modelNameTxt); panel.add(aliasNameLbl); panel.add(aliasTxt); panel.add(prompLbl); panel.add(bsSystemLab); panel.add(bsTxt); panel.add(csSystemLab); panel.add(csTxt); panel.add(sequenceLab); panel.add(sequenceTxt); // panel.add(moduleNoLab); // panel.add(moduleNoTxt); panel.add(imageLab); panel.add(imageTxt); panel.add(imageConentLab); panel.add(imageButton); panel.add(descriptionLabel); panel.add(jsDescription); panel.add(isValid); // moduleNoTxt.setEnabled(false); imageTxt.setEnabled(false); middlePanel.setLayout(new BorderLayout()); middlePanel.add(textField1, BorderLayout.NORTH); middlePanel.add(panel, BorderLayout.CENTER); middlePanel.add(textField2, BorderLayout.SOUTH); } 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 controlButtons(){ modifyButton.setEnabled(false); deleteButton.setEnabled(false); addOperateButton.setEnabled(false); } // private void initModuleNo(){ // int moduleNo = 0; // try { // moduleNo = modelDelegate.getAutoModuleNo(); // } catch (VCIException e) { // e.printStackTrace(); // VCIOptionPane.showError(LogonApplication.frame,LocaleDisplay.getI18nString(e, "RMIPFramework", getLocale())); // return; // } // moduleNoTxt.setText(String.valueOf(moduleNo)); // } /** *Description: 面板底部布局
* *@author ligang *@time 2011-6-2 *@return void * @param bottomPanel */ private void initBottom(JPanel bottomPanel) { addButton.setText(LocaleDisplay.getI18nString("rmip.framework.systemFunctionTree.modelManagment.addButton", "RMIPFramework", getLocale())); addButton.setIcon(new BundleImage().createImageIcon("create.gif"));//添加控件 modifyButton.setText(LocaleDisplay.getI18nString("rmip.framework.systemFunctionTree.modelManagment.modifyButton", "RMIPFramework", getLocale())); modifyButton.setIcon(new BundleImage().createImageIcon("modify.gif"));//修改控件 deleteButton.setText(LocaleDisplay.getI18nString("rmip.framework.systemFunctionTree.modelManagment.deleteButton", "RMIPFramework", getLocale())); deleteButton.setIcon(new BundleImage().createImageIcon("delete.gif"));//删除控件 addOperateButton.setText(LocaleDisplay.getI18nString("rmip.framework.systemFunctionTree.modelManagment.addOperationTypeButton", "RMIPFramework", getLocale())); addOperateButton.setIcon(new BundleImage().createImageIcon("grouplist.gif"));//增加操作类型 delNonSysBtn.setText(LocaleDisplay.getI18nString("rmip.framework.systemFunctionTree.modelManagment.delNonSysBtn", "RMIPFramework", getLocale())); delNonSysBtn.setIcon(new BundleImage().createImageIcon("delete.gif"));//删除控件 delBusiBtn.setText(LocaleDisplay.getI18nString("rmip.framework.systemFunctionTree.modelManagment.delBusiBtn", "RMIPFramework", getLocale())); delBusiBtn.setIcon(new BundleImage().createImageIcon("delete.gif"));//删除控件 bottomPanel.add(addButton); bottomPanel.add(modifyButton); bottomPanel.add(deleteButton); bottomPanel.add(addOperateButton); bottomPanel.add(delNonSysBtn); bottomPanel.add(delBusiBtn); bottomPanel.add(importButton); bottomPanel.add(exportButton); bottomPanel.add(exportSqlButton); //bottomPanel.add(viewI18nButton); } private void initData(FunctionObject obj){ this.modelNameTxt.setText(obj.getName()); this.bsTxt.setText(obj.getResourceB()); this.csTxt.setText(obj.getResourceC()); //this.moduleNoTxt.setText(String.valueOf(obj.getModuleNo())); this.sequenceTxt.setText(String.valueOf(obj.getSequence())); this.imageTxt.setText(obj.getImage()); this.imageConentLab.setIcon(new BundleImage().createImageIcon(obj.getImage())); this.isValid.setSelected(obj.getIsValid()); this.aliasTxt.setText(obj.getAliasName()); this.descriptionText.setText(obj.getDesc()); this.dotNetTxt.setText(obj.getResourceDotNet()); this.mobileTxt.setText(obj.getResourceMobile()); try { /**判断该模块下子对象是模块还是操作,0表示无子节点,1表示是模块,2表示是操作**/ int childType = new FunctionClientDelegate(LogonApplication.getUserEntityObject()).checkChildObject(obj.getId()); if(childType == 1){//有模块 addOperateButton.setEnabled(false); exportButton.setEnabled(false); importButton.setEnabled(false); }else if(childType == 2){ addButton.setEnabled(false); exportButton.setEnabled(false); importButton.setEnabled(false); } } catch (VCIException e) { e.printStackTrace(); VCIOptionPane.showError(LogonApplication.frame,LocaleDisplay.getI18nString(e, "RMIPFramework", getLocale())); } } /** *Description: 按钮动作事件
* *@author Administrator *@time 2011-6-2 *@return void */ private void initAction() { imageButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { selectImages(); } }); addButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { addButton_actionPerformed(); } }); modifyButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { modifyButton_actionPerformed(); } }); deleteButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { deleteButton_actionPerformed(); } }); addOperateButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { addOperateTypeButton_actionPerformed(transmitTreeObject); } }); delNonSysBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { if(ClientSession.getFrameworkService().deleteModules("nonsys")){ JOptionPane.showMessageDialog(getThis(), "删除非系统模块成功", "删除成功", JOptionPane.INFORMATION_MESSAGE); return; } } catch (VCIError e1) { e1.printStackTrace(); JOptionPane.showMessageDialog(getThis(), "删除非系统模块失败", "删除失败", JOptionPane.WARNING_MESSAGE); return; } } }); delBusiBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { if(ClientSession.getFrameworkService().deleteModules("business")){ JOptionPane.showMessageDialog(getThis(), "删除业务模块成功", "删除成功", JOptionPane.INFORMATION_MESSAGE); return; } } catch (VCIError e1) { e1.printStackTrace(); JOptionPane.showMessageDialog(getThis(), "删除业务模块失败", "删除失败", JOptionPane.WARNING_MESSAGE); return; } } }); /** * 导出功能模块管理树结构 * add by caill * * */ exportButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { exportTable(); } }); importButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { importTable(); } }); exportSqlButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { // TODO Auto-generated method stub exportTxt(); } }); // viewI18nButton.addActionListener(new ActionListener() { // // @Override // public void actionPerformed(ActionEvent arg0) { // // TODO Auto-generated method stub // i18nTable(); // } // }); } //add by caill start 2015.12.8 为功能模块及模块下的操作添加导出sql功能 public void exportTxt(){ int size = 0; try { size = modelDelegate.getAllModelManagementNum(); } catch (VCIException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } String[][] plDatas = new String[size][23]; try { plDatas = modelDelegate.getAllDatas(size); } catch (VCIException e) { // TODO Auto-generated catch block e.printStackTrace(); } JFileChooser fileChooser = new JFileChooser(); fileChooser.setDialogTitle("导出sql"); fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); fileChooser.setApproveButtonText("导出"); int result = fileChooser.showOpenDialog(this); if(result == JFileChooser.APPROVE_OPTION){ String dir = fileChooser.getSelectedFile().getAbsolutePath(); if(expData(dir,plDatas)==true){ JOptionPane.showMessageDialog(BtmPanel.getInstance(), "导出成功", "导出成功", JOptionPane.INFORMATION_MESSAGE); }else{ JOptionPane.showMessageDialog(BtmPanel.getInstance(), "导出失败", "导出失败", JOptionPane.INFORMATION_MESSAGE); } } } public boolean expData(String dir, String[][] plDatas){ new File(dir).mkdir(); File file = new File(dir + "/plfuncoperation.sql"); try { FileWriter w = new FileWriter(file); BufferedWriter bw = new BufferedWriter(w); System.out.println("长度为:"+plDatas.length); for(int i=0;iDescription: 添加按钮事件
* *@author ligang *@time 2011-6-2 *@return void */ private void addButton_actionPerformed() { //获取当前选中节点 System.out.println(""); if (transmitTreeObject.getCurrentTreeNode() == null) { VCIOptionPane.showMessage(this, LocaleDisplay.getI18nString("rmip.framework.systemFunctionTree.root.notSelect", "RMIPFramework", getLocale())); return; } FunctionObject obj = check("add"); if(obj == null) { return ; } try { //往数据库里插入新建模块数据 // int num = modelDelegate.getAutoModuleNo(); // obj.setModuleNo(num); String puid = modelDelegate.saveModule(obj); /** * 返回值:1,表示模块名称重复 * 2,表示模块标识重复 * 3, 模板别名存在重复 */ if(puid.equals("1")){ VCIOptionPane.showMessage(LogonApplication.frame, "模块名称重复,请修改!"); return; }else if(puid.equals("2")){ VCIOptionPane.showMessage(LogonApplication.frame, "模块标识重复,请修改!"); return; }else if(puid.equals("3")) { VCIOptionPane.showMessage(LogonApplication.frame, "模块别名重复,请修改!"); return; // }else if (puid.equals("4")) { // VCIOptionPane.showMessage(LogonApplication.frame, "模块编号重复,请修改!"); // return; } obj.setId(puid); VCIBaseTreeNode attrViewNode = new VCIBaseTreeNode(obj.getName(), obj); VCIBaseTreeModel model= transmitTreeObject.getTreeModel(); int count=transmitTreeObject.getCurrentTreeNode().getChildCount(); if(transmitTreeObject.getCurrentTreeNode().isExpand()){ model.insertNodeInto(attrViewNode, transmitTreeObject.getCurrentTreeNode(), transmitTreeObject.getCurrentTreeNode().getChildCount()); transmitTreeObject.getTree().setSelectionPath(new TreePath(attrViewNode.getPath())); attrViewNode.setExpand(true); attrViewNode.setLeaf(true); }else{ transmitTreeObject.getTree().expandPath(new TreePath(transmitTreeObject.getCurrentTreeNode().getPath())); transmitTreeObject.getTree().setSelectionPath(new TreePath(transmitTreeObject.getCurrentTreeNode().getPath())); } transmitTreeObject.getCurrentTreeNode().setLeaf(false); } catch (VCIException e) { VCIOptionPane.showError(LogonApplication.frame,LocaleDisplay.getI18nString(e, "RMIPFramework", getLocale())); return ; } } /** *Description: 删除事件
* *@author xf *@time 2012-5-15 *@return void */ private void deleteButton_actionPerformed() { //获取当前选中节点 if (transmitTreeObject.getCurrentTreeNode() == null) { VCIOptionPane.showMessage(this, LocaleDisplay.getI18nString("rmip.framework.systemFunctionTree.model.delete", "RMIPFramework", getLocale())); return ; } int i = VCIOptionPane.showConfirmDialog(this, LocaleDisplay.getI18nString("rmip.framework.systemFunctionTree.model.deleteQuery", "RMIPFramework", getLocale()),LocaleDisplay.getI18nString("rmip.framework.friend.message.dialog.title", "RMIPFramework", getLocale()),VCIOptionPane.YES_NO_OPTION); if (i != 0) { return; } String res = ""; try { Object object = transmitTreeObject.getCurrentTreeNode().getObj(); String puid = ""; if(object instanceof FunctionObject) { FunctionObject plFunObject = (FunctionObject) object; puid = plFunObject.getId(); }else if("business".equals(object)) { puid = "business"; }else if("system".equals(object)) { puid = "system"; } res = modelDelegate.deleteModule(puid); /** * 返回值:1表示模块在权限模块已经有授权信息,无法删除 */ if(res.equals("1")){ VCIOptionPane.showMessage(LogonApplication.frame, "当前模块(或下级模块)已经存在授权信息,无法删除。"); return; } } catch (VCIException e) { VCIOptionPane.showError(LogonApplication.frame,LocaleDisplay.getI18nString(e, "RMIPFramework", getLocale())); return; } VCIBaseTreeNode parentNode = (VCIBaseTreeNode)transmitTreeObject.getCurrentTreeNode().getParent(); VCIBaseTreeModel model = transmitTreeObject.getTreeModel(); model.removeNodeFromParent(transmitTreeObject.getCurrentTreeNode()); transmitTreeObject.getTree().setSelectionPath(new TreePath(parentNode.getPath())); transmitTreeObject.setCurrentTreeNode(parentNode); } /** *Description: 修改模块事件
* *@author xf *@time 2012-5-15 *@return void */ private void modifyButton_actionPerformed() { //获取当前选中节点 if (transmitTreeObject.getCurrentTreeNode() == null) { VCIOptionPane.showMessage(this, LocaleDisplay.getI18nString("rmip.framework.systemFunctionTree.root.notSelect", "RMIPFramework", getLocale())); return ; } FunctionObject obj = check("update"); try { String res = ""; //更新数据库 res = modelDelegate.updateModule(obj); /** * 返回:1表示模块名重复。 * 2表示模块标识重复。 * 3标示模块别名重复。 */ if(res.equals("1")){ VCIOptionPane.showMessage(LogonApplication.frame, "模块名称重复,请修改!"); return; }else if(res.equals("2")){ VCIOptionPane.showMessage(LogonApplication.frame, "模块标识重复,请修改!"); return; }else if(res.equals("3")) { VCIOptionPane.showMessage(LogonApplication.frame, "模块别名重复,请修改!"); return; } else if (res.equals("4")) { VCIOptionPane.showMessage(LogonApplication.frame, "模块编号重复,请修改!"); return; } else { VCIOptionPane.showMessage(this, LocaleDisplay.getI18nString("rmip.framework.systemFunctionTree.model.modifyInfo", "RMIPFramework", getLocale())); transmitTreeObject.getCurrentTreeNode().setUserObject(obj.getName()); transmitTreeObject.getCurrentTreeNode().setObj(obj); transmitTreeObject.getTreeModel().nodeChanged(transmitTreeObject.getCurrentTreeNode()); } } catch (VCIException e) { VCIOptionPane.showError(LogonApplication.frame,LocaleDisplay.getI18nString(e, "RMIPFramework", getLocale())); return; } } /** *Description: 页面输入的校验
* *@author xf *@time 2012-5-15 *@return FunctionObject * @return */ private FunctionObject check(String type) { FunctionObject obj = new FunctionObject(); Object currentObj = transmitTreeObject.getCurrentTreeNode().getObj(); FunctionObject objForTree = new FunctionObject(); if(currentObj instanceof FunctionObject) { objForTree = (FunctionObject) currentObj; } // FunctionObject objForTree = (FunctionObject)transmitTreeObject.getCurrentTreeNode().getObj(); // if(type.equals("update")){ // obj = (FunctionObject)transmitTreeObject.getCurrentTreeNode().getObj(); // } //获取表单输入的值 String modelName = modelNameTxt.getText().trim(); String csIdentity = csTxt.getText().trim(); String bsIdentity = bsTxt.getText().trim(); String aliasName = aliasTxt.getText().trim(); String resDotNet = dotNetTxt.getText(); String resMobile = mobileTxt.getText(); //int moduleNo = transferStringToNum(moduleNoTxt.getText()); int sequence = transferStringToNum(sequenceTxt.getText()); String description = descriptionText.getText(); if("".equals(modelName) || "null".equals(modelName) || modelName == null) { VCIOptionPane.showMessage(this, LocaleDisplay.getI18nString("rmip.framework.systemFunctionTree.modelNmae.isNull", "RMIPFramework", getLocale())); return null; }else if(modelName.length() > 128) { VCIOptionPane.showMessage(this, LocaleDisplay.getI18nString("rmip.framework.systemFunctionTree.modelNmae.lenght", "RMIPFramework", getLocale())); return null; }else if(description.length() > 255) { VCIOptionPane.showMessage(this, LocaleDisplay.getI18nString("rmip.framework.systemFunctionTree.desc.lenght", "RMIPFramework", getLocale())); return null; }/**else if("".equals(csIdentity) || "null".equals(csIdentity) || csIdentity == null) { VCIOptionPane.showMessage(this, LocaleDisplay.getI18nString("rmip.framework.systemFunctionTree.cs.name", "RMIPFramework", getLocale())); return null; }**/else if(csIdentity != null && !"".equals(csIdentity) && csIdentity.length() > 255) { VCIOptionPane.showMessage(this, LocaleDisplay.getI18nString("rmip.framework.systemFunctionTree.cs.lenght", "RMIPFramework", getLocale())); return null; } else if(resDotNet != null && !"".equals(resDotNet) && resDotNet.length() > 255) { VCIOptionPane.showMessage(this, LocaleDisplay.getI18nString("rmip.framework.systemFunctionTree.dotnet.lenght", "RMIPFramework", getLocale())); return null; }else if(resMobile != null && !"".equals(resMobile) && csIdentity.length() > 255) { VCIOptionPane.showMessage(this, LocaleDisplay.getI18nString("rmip.framework.systemFunctionTree.mobile.lenght", "RMIPFramework", getLocale())); return null; // }else if (moduleNo < 0) { // VCIOptionPane.showMessage(this, LocaleDisplay.getI18nString("rmip.framework.systemFunctionTree.moduleNo.isNull", "RMIPFramework", getLocale())); // return null; } else if (sequence < 0) { VCIOptionPane.showMessage(this, LocaleDisplay.getI18nString("rmip.framework.systemFunctionTree.sequence.isNull", "RMIPFramework", getLocale())); return null; } if(type.equals("add")){ //给object对象赋值 Object object = transmitTreeObject.getCurrentTreeNode().getObj(); String parentId = ""; if(object instanceof FunctionObject) { FunctionObject plFunObject = (FunctionObject)object; parentId = plFunObject.getId(); }else if("business".equals(object)) { parentId = "business"; }else if("system".equals(object)) { parentId = "system"; } obj.setParentId(parentId); }else{ obj.setId(objForTree.getId()); obj.setParentId(objForTree.getParentId()); } obj.setName(modelName); obj.setResourceC(csIdentity); obj.setDesc(description); obj.setResourceB(bsIdentity); obj.setSuffixC(""); obj.setSuffixB(""); obj.setSequence(sequence); //obj.setModuleNo(moduleNo); obj.setImage(imageTxt.getText()); obj.setIsValid(isValid.isSelected());//1有效0无效 obj.setAliasName(aliasName); obj.setResourceDotNet(resDotNet); obj.setResourceMobile(resMobile); return obj; } private int transferStringToNum(String input) { int output = -1; try { output = Integer.parseInt(input); } catch (Throwable e) { output = -1; } return output; } private void addOperateTypeButton_actionPerformed(TransmitTreeObject transmitTreeObject) { OperationTypeTreeDialog operationDialog = new OperationTypeTreeDialog(transmitTreeObject); operationDialog.setVisible(true); } private JPanel getThis(){ return this; } }