MyBatis Generator简称MBG,是MyBatis 官方出的代码生成器。MBG能够自动生成实体类、Mapper接口以及对应的XML文件,能够在一定程度上减轻开发人员的工作量。本文介绍了使用MBG Maven插件的使用方法。
package zjexec.main; import java.awt.Color; import java.awt.Dimension; import java.awt.Toolkit; import java.awt.event.MouseEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.util.Arrays; import java.util.List; import java.util.Vector; import javax.swing.BorderFactory; import javax.swing.DefaultCellEditor; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JPasswordField; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.JTextField; import javax.swing.ToolTipManager; import javax.swing.table.JTableHeader; import javax.swing.table.TableColumn; import javax.swing.table.TableColumnModel; import org.apache.log4j.Logger; import zj.check.util.CheckUtil; import zj.java.util.JavaUtil; import zj.jdbc.util.JdbcUtil; import zj.message.util.MessageConstantsUtil; import zj.reflect.util.TypeUtil; import zjexec.swing.ComboxItem; import zjexec.swing.GenerateCodeGUIEvent; import zjexec.swing.TableModel; /** * mybatis自动生成工具类 * * @version 1.00 (2014.09.15) * @author SHNKCS 张军 {@link <a href=http://user.qzone.qq.com/360901061/>张军QQ空间</a>} */ public class GenerateCodeGUI { private transient static final Logger logger = Logger.getLogger(GenerateCodeGUI.class); public JMenuBar jMenuBar; public JMenu jFile, jFileAuthor; public JMenuItem jOpenFile, jSaveFile, jContactFile; public JMenu jHelp; public JFrame jframe; // ComboxItems public ComboxItem dbDriverDefault, dbDriverOracle, dbDriverMysql, dbDmlSaveOrUpdate, dbDmlDelete, entityJspAddOpenTypeDialog, entityJspUpdateOpenTypeDialog, entityJspViewOpenTypeDialog, entityJspConfigFieldViewDetailY, entityDeleteTypePhysicalDelete; // 数据库连接信息 public JLabel dbTypeText, dbUserNameText, dbPasswordText, dbUrlText, dbMenuButTableAbleText; public JPanel dbPanel; public JComboBox dbDriver; public JTextField dbUserName, dbPassword, dbUrl, dbMenuTable, dbMenuButTable; public JCheckBox dbMenuTableAble, dbMenuButTableAdd, dbMenuButTableUpdate, dbMenuButTableDel, dbMenuButTableUndel, dbMenuButTableView; // 基础信息 public JLabel basicModuleNameText, basicSrcDirPathText, basicWebRootDirPathText, basicAuthorText; public JPanel basicPanel; // public JComboBox basicAbsolutePath; public JCheckBox basicAbsolutePathAble; public JTextField basicModuleName, basicSrcDirPath, basicWebRootDirPath, basicAuthor; public JButton basicSrcDirPathBut, basicWebRootDirPathBut; // public ComboxItem selectedAbsolutePath; // 实体信息 public JLabel dbDmlText, entityTableNameText, entityEntityNameText, entityDescriptionText, entityJspAddOpenTypeText, entityJspUpdateOpenTypeText, entityJspViewOpenTypeText, entityJspConfigFieldViewDetailText, entityDeleteTypeText, entityFieldFilterText; public JPanel entityPanel; @Deprecated public JComboBox entityJspAddOpenType, entityJspUpdateOpenType, entityJspViewOpenType; public JComboBox dbDml, entityJspConfigFieldViewDetail, entityDeleteType; public ComboxItem selectedDml, selectedOpenTypeDefault, selectedJspConfigFieldViewDetail, selectedDeleteType; public JTextField entityTableName, entityEntityName, entityDescription; public JCheckBox entityJavaModelFieldFilter, entityJspConfigFieldFilter, entityJspConfigFrozenFieldFilter, entityJspQueryFieldFilter, entityJspAddFieldFilter, entityJspUpdateFieldFilter, entityJspViewFieldFilter; // 实体列表信息 public JPanel entityListPanel; public TableModel entityListTableModel; public JTable entityListTable; public JScrollPane entityListTableScroll; public JButton entityListAddBut, entityListRemoveBut, entityListDbTableBut; public JComboBox entityListJdbcTypes, entityListJavaTypes; // 实体操作信息 public JLabel operatorTypeText; public JPanel operatorPanel; public ComboxItem selectedOperatorType, operatorTypeY; @Deprecated public JComboBox operatorType; public JCheckBox operatorModelXml, operatorModelKeyJava, operatorModelKeysJava, operatorCommonJs, operatorConfigJsp, operatorQueryJsp, operatorAddTabJsp, operatorAddDialogJsp, operatorUpdateTabJsp, operatorUpdateDialogJsp, operatorViewTabJsp, operatorViewDialogJsp, operatorActionJava, operatorPageJava, operatorMapperJava, operatorIServiceJava, operatorServiceJava; public JButton operatorOkBut, operatorDeleteBut; public static GenerateCodeGUI thisFrame = null; Dimension screensize = Toolkit.getDefaultToolkit().getScreenSize(); // int width = (int) screensize.getWidth(); // int height = (int) screensize.getHeight(); // 屏幕的物理大小还需要知道屏幕的dpi 意思是说一英寸多少个象素 // int dpi = Toolkit.getDefaultToolkit().getScreenResolution(); // 然后用象素除以dpi 就可以得到多少英寸了 你要是再不知道英寸怎么转换厘米 那我也不知道怎么帮忙了 public int frameWidth = 1150; public int frameHeight = (int) screensize.getHeight() - 130; public int scrollWidth = frameWidth - 30; public int scrollHeight = frameHeight - 80; // 初使化常量 public static String[] ARY_JDBC_TYPES = null; public static List<String> LIST_JDBC_TYPES = null; public static String[] ARY_JAVA_TYPES = null; public static List<String> LIST_JAVA_TYPES = null; public JPanel scrollPanel; public JScrollPane scroll; /** 面板对应的x轴值 **/ private int panelX = 10; /** 面板对应的y轴值 **/ private int panelY = 5; /** 面板的宽度 **/ private int panelWidth = frameWidth - 70; /** 面板的高度 **/ private int panelYDiff = 10; /** 域对应的x轴值 **/ private int labelX = 10; /** 域对应的y轴值 **/ private int labelY = 20; /** 每行相同区域之间相差的x轴距离 **/ private int labelXDiff = 5; /** 每行不同区域之间相差的x轴距离 **/ private int labelXDiff2 = 10; /** 每行之间相差的y轴距离 **/ private int labelYDiff = 35; /** 每个域的高度 **/ private int heigth = 25; static { ARY_JDBC_TYPES = JavaUtil.split(MessageConstantsUtil.getConstantValueByMemory("select.text.jdbcTypes"), "|"); LIST_JDBC_TYPES = Arrays.asList(ARY_JDBC_TYPES); ARY_JAVA_TYPES = JavaUtil.split(MessageConstantsUtil.getConstantValueByMemory("select.text.javaTypes"), "|"); LIST_JAVA_TYPES = Arrays.asList(ARY_JAVA_TYPES); } /** * 主程序 * * @param args * @throws Exception */ public static void main(String[] args) throws Exception { thisFrame = new GenerateCodeGUI(); thisFrame.setFrame(); GenerateCodeGUIEvent event = new GenerateCodeGUIEvent(thisFrame); event.initAll(); thisFrame.showMe(); } /** * 提示消息 * * @param component * 控件对象 * @param messageKey * 消息key * @author 张军 * @date 2015-11-03 21:59:00 * @modifiyNote * @version 1.0 * @return 提示控件对象 */ public static JComponent tip(JComponent component, String messageKey) { component.setToolTipText(MessageConstantsUtil.getConstantValueByMemory(messageKey)); return component; } /** * 主窗口 */ public void setFrame() { // 实例化主体面板 // jframe = new JFrame(MessageConstantsUtil.getConstantValueByMemory("jframe.text.title")); jframe = new JFrame("mybatis-自动生成代码-张军开发(QQ:360901061)"); // 添加提示消息 ToolTipManager.sharedInstance().setDismissDelay(TypeUtil.Primitive.intValue(MessageConstantsUtil.getConstantValueByMemory("tip.timeOut")));// 设置为10秒 // 实例化菜单 createMenuBar(); // 关闭窗口 addEventHandler(); // 设置下拉框值 setComboxItems(); // 实例化数据库连接信息控件 createDbPanel(); // 实例化基础信息控件 createBasicPanel(); // 实例化实体信息控件 createEntityPanel(); // 实例化实体列表信息控件 createEntityListPanel(); // 实例化操作信息控件 createOperatorPanel(); // 实例化滚动面板 createScroll(); // 设置border setBorder(); // 添加框架 addFramework(); // ********************************************* } /** * 添加框架 * * @author 张军 * @date 2015-11-03 21:59:00 * @modifiyNote * @version 1.0 */ private void addFramework() { // 添加框架 jframe.add(scroll); jframe.setJMenuBar(jMenuBar); // 设置图片 // jframe.setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getClassLoader().getResource("/folderopen.ico"))); logger.debug(MessageConstantsUtil.getConstantValueByMemory("jframe.text.title") + "-控件添加完成"); // 主要是这句代码,设置panel的首选大小,同时保证宽高大于JScrollPane的宽高,这样下面的JScrollPane才会出现滚动条 scrollPanel.setPreferredSize(new Dimension(panelWidth, operatorPanel.getY() + operatorPanel.getHeight() + 30)); // 设置layout为自定义 dbPanel.setLayout(null); basicPanel.setLayout(null); entityPanel.setLayout(null); entityListPanel.setLayout(null); operatorPanel.setLayout(null); scrollPanel.setLayout(null); jframe.setLayout(null); logger.debug(MessageConstantsUtil.getConstantValueByMemory("jframe.text.title") + "-位置设置完成"); } /** * 设置border * * @author 张军 * @date 2015-11-03 21:59:00 * @modifiyNote * @version 1.0 */ private void setBorder() { dbPanel.setBorder(BorderFactory.createTitledBorder(MessageConstantsUtil.getConstantValueByMemory("dbPanel.text.title"))); basicPanel.setBorder(BorderFactory.createTitledBorder(MessageConstantsUtil.getConstantValueByMemory("basicPanel.text.title"))); entityPanel.setBorder(BorderFactory.createTitledBorder(MessageConstantsUtil.getConstantValueByMemory("entityPanel.text.title"))); entityListPanel.setBorder(BorderFactory.createTitledBorder(MessageConstantsUtil.getConstantValueByMemory("entityListPanel.text.title"))); operatorPanel.setBorder(BorderFactory.createTitledBorder(MessageConstantsUtil.getConstantValueByMemory("operatorPanel.text.title"))); logger.debug(MessageConstantsUtil.getConstantValueByMemory("jframe.text.title") + "-border设置完成"); } /** * 实例化滚动面板 * * @author 张军 * @date 2015-11-03 21:59:00 * @modifiyNote * @version 1.0 */ private void createScroll() { // new GridLayout(2, 1) // 实例化滚动面板控件 scrollPanel = new JPanel(); // 实例化滚动条控件 scroll = new JScrollPane(scrollPanel); // 分别设置水平和垂直滚动条总是出现 scroll.setBounds(10, 10, scrollWidth, scrollHeight); logger.debug(MessageConstantsUtil.getConstantValueByMemory("scrollPanel.text.title") + "-位置设置完成"); // 添加控件 scrollPanel.add(dbPanel); scrollPanel.add(basicPanel); scrollPanel.add(entityPanel); scrollPanel.add(entityListPanel); scrollPanel.add(operatorPanel); } /** * 实例化操作信息控件 * * @author 张军 * @date 2015-11-03 21:59:00 * @modifiyNote * @version 1.0 */ private void createOperatorPanel() { operatorPanel = new JPanel(); operatorOkBut = new JButton(MessageConstantsUtil.getConstantValueByMemory("operatorPanel.text.ok")); operatorDeleteBut = new JButton(MessageConstantsUtil.getConstantValueByMemory("operatorPanel.text.delete")); // 设置位置 operatorPanel.setBounds(panelX, entityListPanel.getY() + entityListPanel.getHeight() + panelYDiff, panelWidth, 50 + labelYDiff); // 第一行 operatorOkBut.setBounds(labelX + scrollWidth / 2 - labelX * 10, labelYDiff, 100, heigth); operatorDeleteBut.setBounds(operatorOkBut.getX() + operatorOkBut.getWidth() + labelXDiff + labelXDiff2, labelYDiff, 100, heigth); logger.debug(MessageConstantsUtil.getConstantValueByMemory("operatorPanel.text.title") + "-位置设置完成"); operatorPanel.add(operatorOkBut); operatorPanel.add(operatorDeleteBut); logger.debug(MessageConstantsUtil.getConstantValueByMemory("operatorPanel.text.title") + "-控件添加完成"); } /** * 实例化实体信息控件 * * @author 张军 * @date 2015-11-03 21:59:00 * @modifiyNote * @version 1.0 */ private void createEntityPanel() { entityPanel = new JPanel(); // 第一行 operatorTypeText = new JLabel(MessageConstantsUtil.getConstantValueByMemory("operatorPanel.text.type")); operatorModelXml = new JCheckBox(MessageConstantsUtil.getConstantValueByMemory("operatorPanel.text.model.xml")); operatorModelKeyJava = new JCheckBox(MessageConstantsUtil.getConstantValueByMemory("operatorPanel.text.Model.Key.java")); operatorModelKeysJava = new JCheckBox(MessageConstantsUtil.getConstantValueByMemory("operatorPanel.text.Model.Keys.java")); operatorCommonJs = new JCheckBox(MessageConstantsUtil.getConstantValueByMemory("operatorPanel.text.common.js")); operatorConfigJsp = new JCheckBox(MessageConstantsUtil.getConstantValueByMemory("operatorPanel.text.config.jsp")); operatorQueryJsp = new JCheckBox(MessageConstantsUtil.getConstantValueByMemory("operatorPanel.text.query.jsp")); operatorAddTabJsp = new JCheckBox(MessageConstantsUtil.getConstantValueByMemory("operatorPanel.text.add.tab.jsp")); operatorAddDialogJsp = new JCheckBox(MessageConstantsUtil.getConstantValueByMemory("operatorPanel.text.add.dialog.jsp")); operatorUpdateTabJsp = new JCheckBox(MessageConstantsUtil.getConstantValueByMemory("operatorPanel.text.update.tab.jsp")); operatorUpdateDialogJsp = new JCheckBox(MessageConstantsUtil.getConstantValueByMemory("operatorPanel.text.update.dialog.jsp")); operatorViewTabJsp = new JCheckBox(MessageConstantsUtil.getConstantValueByMemory("operatorPanel.text.view.tab.jsp")); operatorViewDialogJsp = new JCheckBox(MessageConstantsUtil.getConstantValueByMemory("operatorPanel.text.view.dialog.jsp")); operatorActionJava = new JCheckBox(MessageConstantsUtil.getConstantValueByMemory("operatorPanel.text.Action.java")); operatorPageJava = new JCheckBox(MessageConstantsUtil.getConstantValueByMemory("operatorPanel.text.Page.java")); operatorMapperJava = new JCheckBox(MessageConstantsUtil.getConstantValueByMemory("operatorPanel.text.Mapper.java")); operatorIServiceJava = new JCheckBox(MessageConstantsUtil.getConstantValueByMemory("operatorPanel.text.IService.java")); operatorServiceJava = new JCheckBox(MessageConstantsUtil.getConstantValueByMemory("operatorPanel.text.Service.java")); // 第二行 // 添加页面 entityJspAddOpenTypeText = new JLabel(MessageConstantsUtil.getConstantValueByMemory("entityPanel.text.jspAddOpenType")); // 编辑页面 entityJspUpdateOpenTypeText = new JLabel(MessageConstantsUtil.getConstantValueByMemory("entityPanel.text.jspUpdateOpenType")); // 查看页面 entityJspViewOpenTypeText = new JLabel(MessageConstantsUtil.getConstantValueByMemory("entityPanel.text.jspViewOpenType")); // 查看(列表)页面 entityJspConfigFieldViewDetailText = new JLabel(MessageConstantsUtil.getConstantValueByMemory("entityPanel.text.jspConfigFieldViewDetail")); // 查看(列表)页面 entityDeleteTypeText = new JLabel(MessageConstantsUtil.getConstantValueByMemory("entityPanel.text.deleteType")); // 第三行 // 设置位置 entityPanel.setBounds(panelX, basicPanel.getY() + basicPanel.getHeight() + panelYDiff, panelWidth, 140 + labelYDiff); // 第一行 // 操作类型 operatorTypeText.setBounds(labelX, labelY, 60, heigth); operatorType.setBounds(operatorTypeText.getX() + operatorTypeText.getWidth() + labelXDiff, labelY, 100, heigth); // 添加复选框 operatorModelKeyJava.setBounds(operatorTypeText.getX() + operatorTypeText.getWidth() + labelXDiff, labelY, 150, heigth); operatorModelKeysJava.setBounds(operatorModelKeyJava.getX() + operatorModelKeyJava.getWidth() + labelXDiff, labelY, 150, heigth); operatorMapperJava.setBounds(operatorModelKeysJava.getX() + operatorModelKeysJava.getWidth() + labelXDiff, labelY, 150, heigth); operatorPageJava.setBounds(operatorMapperJava.getX() + operatorMapperJava.getWidth() + labelXDiff, labelY, 150, heigth); operatorModelXml.setBounds(operatorPageJava.getX() + operatorPageJava.getWidth() + labelXDiff, labelY, 150, heigth); operatorIServiceJava.setBounds(operatorModelXml.getX() + operatorModelXml.getWidth() + labelXDiff, labelY, 150, heigth); // 第二行 operatorServiceJava.setBounds(operatorTypeText.getX() + operatorTypeText.getWidth() + labelXDiff, operatorModelKeyJava.getY() + labelYDiff, 150, heigth); operatorActionJava.setBounds(operatorServiceJava.getX() + operatorServiceJava.getWidth() + labelXDiff, operatorModelKeyJava.getY() + labelYDiff, 150, heigth); operatorCommonJs.setBounds(operatorActionJava.getX() + operatorActionJava.getWidth() + labelXDiff, operatorModelKeyJava.getY() + labelYDiff, 150, heigth); operatorQueryJsp.setBounds(operatorCommonJs.getX() + operatorCommonJs.getWidth() + labelXDiff, operatorModelKeyJava.getY() + labelYDiff, 150, heigth); operatorConfigJsp.setBounds(operatorQueryJsp.getX() + operatorQueryJsp.getWidth() + labelXDiff, operatorModelKeyJava.getY() + labelYDiff, 150, heigth); operatorAddTabJsp.setBounds(operatorConfigJsp.getX() + operatorConfigJsp.getWidth() + labelXDiff, operatorModelKeyJava.getY() + labelYDiff, 150, heigth); // 第三行 operatorAddDialogJsp.setBounds(operatorTypeText.getX() + operatorTypeText.getWidth() + labelXDiff, operatorServiceJava.getY() + labelYDiff, 150, heigth); operatorUpdateTabJsp.setBounds(operatorAddDialogJsp.getX() + operatorAddDialogJsp.getWidth() + labelXDiff, operatorServiceJava.getY() + labelYDiff, 150, heigth); operatorUpdateDialogJsp.setBounds(operatorUpdateTabJsp.getX() + operatorUpdateTabJsp.getWidth() + labelXDiff, operatorServiceJava.getY() + labelYDiff, 150, heigth); operatorViewTabJsp.setBounds(operatorUpdateDialogJsp.getX() + operatorUpdateDialogJsp.getWidth() + labelXDiff, operatorServiceJava.getY() + labelYDiff, 150, heigth); operatorViewDialogJsp.setBounds(operatorViewTabJsp.getX() + operatorViewTabJsp.getWidth() + labelXDiff, operatorServiceJava.getY() + labelYDiff, 150, heigth); // 第二行 entityJspAddOpenTypeText.setBounds(labelX, operatorAddDialogJsp.getY() + labelYDiff, 70, heigth); entityJspAddOpenType.setBounds(entityJspAddOpenTypeText.getX() + entityJspAddOpenTypeText.getWidth(), operatorAddDialogJsp.getY() + labelYDiff, 70, heigth); entityJspUpdateOpenTypeText.setBounds(entityJspAddOpenType.getX() + entityJspAddOpenType.getWidth() + labelXDiff + labelXDiff2, operatorAddDialogJsp.getY() + labelYDiff, 70, heigth); entityJspUpdateOpenType.setBounds(entityJspUpdateOpenTypeText.getX() + entityJspUpdateOpenTypeText.getWidth() + labelXDiff, operatorAddDialogJsp.getY() + labelYDiff, 70, heigth); entityJspViewOpenTypeText.setBounds(entityJspUpdateOpenType.getX() + entityJspUpdateOpenType.getWidth() + labelXDiff + labelXDiff2, operatorAddDialogJsp.getY() + labelYDiff, 70, heigth); entityJspViewOpenType.setBounds(entityJspViewOpenTypeText.getX() + entityJspViewOpenTypeText.getWidth() + labelXDiff, operatorAddDialogJsp.getY() + labelYDiff, 70, heigth); entityJspConfigFieldViewDetailText.setBounds(labelX, operatorAddDialogJsp.getY() + labelYDiff, 70, heigth); entityJspConfigFieldViewDetail.setBounds(entityJspConfigFieldViewDetailText.getX() + entityJspConfigFieldViewDetailText.getWidth() + labelXDiff, operatorAddDialogJsp.getY() + labelYDiff, 70, heigth); entityDeleteTypeText.setBounds(entityJspConfigFieldViewDetail.getX() + entityJspConfigFieldViewDetail.getWidth() + labelXDiff + labelXDiff2, operatorAddDialogJsp.getY() + labelYDiff, 80, heigth); entityDeleteType.setBounds(entityDeleteTypeText.getX() + entityDeleteTypeText.getWidth() + labelXDiff, operatorAddDialogJsp.getY() + labelYDiff, 80, heigth); // 第三行 logger.debug(MessageConstantsUtil.getConstantValueByMemory("entityPanel.text.title") + "-位置设置完成"); // 添加控件 // 第一行 // 添加控件 entityPanel.add(tip(operatorTypeText, "tip.operatorPanel.text.type")); // entityPanel.add(tip(operatorType, "tientityPanelel.text.type")); entityPanel.add(operatorModelXml); entityPanel.add(operatorModelKeyJava); entityPanel.add(operatorModelKeysJava); entityPanel.add(operatorCommonJs); entityPanel.add(operatorConfigJsp); entityPanel.add(operatorQueryJsp); entityPanel.add(operatorAddTabJsp); entityPanel.add(operatorAddDialogJsp); entityPanel.add(operatorUpdateTabJsp); entityPanel.add(operatorUpdateDialogJsp); entityPanel.add(operatorViewTabJsp); entityPanel.add(operatorViewDialogJsp); entityPanel.add(operatorActionJava); entityPanel.add(operatorPageJava); entityPanel.add(operatorMapperJava); entityPanel.add(operatorIServiceJava); entityPanel.add(operatorServiceJava); // 第二行 // entityPanel.add(entityJspAddOpenTypeText); // entityPanel.add(entityJspAddOpenType); // entityPanel.add(entityJspUpdateOpenTypeText); // entityPanel.add(entityJspUpdateOpenType); // entityPanel.add(entityJspViewOpenTypeText); // entityPanel.add(entityJspViewOpenType); entityPanel.add(entityJspConfigFieldViewDetailText); entityPanel.add(entityJspConfigFieldViewDetail); entityPanel.add(entityDeleteTypeText); entityPanel.add(entityDeleteType); // 第三行 logger.debug(MessageConstantsUtil.getConstantValueByMemory("entityPanel.text.title") + "-控件添加完成"); } /** * 实例化实体列表信息控件 * * @author 张军 * @date 2015-11-03 21:59:00 * @modifiyNote * @version 1.0 */ @SuppressWarnings("serial") private void createEntityListPanel() { entityListPanel = new JPanel(); entityListTableModel = new TableModel(); entityListTable = new JTable(entityListTableModel) { protected JTableHeader createDefaultTableHeader() { return new JTableHeader(columnModel) { public String getToolTipText(MouseEvent e) { java.awt.Point p = e.getPoint(); // int index = columnModel.getColumnIndexAtX(p.x); // int realIndex = columnModel.getColumn(index).getModelIndex(); int index = columnModel.getColumnIndexAtX(p.x); TableColumn tcolumn = columnModel.getColumn(index); int realIndex = tcolumn.getModelIndex(); String headerValue = JavaUtil.objToStr(tcolumn.getHeaderValue()); if (MessageConstantsUtil.getConstantValueByMemory("entityListPanel.titleNames.col3").equals(headerValue)) { return MessageConstantsUtil.getConstantValueByMemory("tip.entityListPanel.titleNames.col3"); } else if (MessageConstantsUtil.getConstantValueByMemory("entityListPanel.titleNames.col4").equals(headerValue)) { return MessageConstantsUtil.getConstantValueByMemory("tip.entityListPanel.titleNames.col4"); } else if (realIndex >= 7 - 1 && realIndex <= 13 - 1) { return MessageConstantsUtil.getConstantValueByMemory("tip.entityListPanel.titleNames.col*.filter"); } else if (realIndex >= 14 - 1 && realIndex <= 27 - 1) { return MessageConstantsUtil.getConstantValueByMemory("tip.entityListPanel.titleNames.col*.query"); } else { return null; } } }; } }; // // 悬浮提示单元格的值 // entityListTable.addMouseMotionListener(new MouseAdapter() { // public void mouseMoved(MouseEvent e) { // int row = entityListTable.rowAtPoint(e.getPoint()); // int col = entityListTable.columnAtPoint(e.getPoint()); // if (row > -1 && col > -1) { // System.out.println(row); // if (col == 2) { // entityListTable.setToolTipText(MessageConstantsUtil.getConstantValueByMemory("tip.table.col3"));// 悬浮显示单元格内容 // } // Object value=table.getValueAt(row, col); // if(null!=value && !"".equals(value)) // table.setToolTipText(value.toString());//悬浮显示单元格内容 // else // table.setToolTipText(null);//关闭提示 // System.out.println(col); // } // } // }); entityListTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); entityListTable.getTableHeader().setReorderingAllowed(false); // 不可整列移动 // entityListTable.getTableHeader().setResizingAllowed(false); // 不可拉动表格 entityListTable.setBackground(Color.white); TableColumnModel tableColumnModel = this.entityListTable.getColumnModel(); String[] titleNamesTemp = JavaUtil.split(MessageConstantsUtil.getConstantValueByMemory("entityListPanel.titleNames"), "|"); for (int i = 0; i < titleNamesTemp.length; i++) { String titleName = titleNamesTemp[i]; String[] jComboBoxColumnAry = JavaUtil.split(titleName, ":"); if (jComboBoxColumnAry.length == 3) { if (CheckUtil.isNotNull(jComboBoxColumnAry[2])) { tableColumnModel.getColumn(i).setPreferredWidth(TypeUtil.Primitive.intValue(jComboBoxColumnAry[2])); } if ("jdbcType".equalsIgnoreCase(jComboBoxColumnAry[1])) { tableColumnModel.getColumn(i).setCellEditor(new DefaultCellEditor(this.entityListJdbcTypes)); } else if ("javaType".equalsIgnoreCase(jComboBoxColumnAry[1])) { tableColumnModel.getColumn(i).setCellEditor(new DefaultCellEditor(this.entityListJavaTypes)); } } } entityListTableScroll = new JScrollPane(entityListTable); // 过虑字段反转 entityFieldFilterText = new JLabel(MessageConstantsUtil.getConstantValueByMemory("entityPanel.text.fieldFilter")); entityJavaModelFieldFilter = new JCheckBox(MessageConstantsUtil.getConstantValueByMemory("entityPanel.text.javaModelFieldFilter")); entityJspConfigFieldFilter = new JCheckBox(MessageConstantsUtil.getConstantValueByMemory("entityPanel.text.jspConfigFieldFilter")); entityJspConfigFrozenFieldFilter = new JCheckBox(MessageConstantsUtil.getConstantValueByMemory("entityPanel.text.jspConfigFrozenFieldFilter")); entityJspQueryFieldFilter = new JCheckBox(MessageConstantsUtil.getConstantValueByMemory("entityPanel.text.jspQueryFieldFilter")); entityJspAddFieldFilter = new JCheckBox(MessageConstantsUtil.getConstantValueByMemory("entityPanel.text.jspAddFieldFilter")); entityJspUpdateFieldFilter = new JCheckBox(MessageConstantsUtil.getConstantValueByMemory("entityPanel.text.jspUpdateFieldFilter")); entityJspViewFieldFilter = new JCheckBox(MessageConstantsUtil.getConstantValueByMemory("entityPanel.text.jspViewFieldFilter")); // 操作按钮 entityListAddBut = new JButton(MessageConstantsUtil.getConstantValueByMemory("entityListPanel.text.addBut")); entityListRemoveBut = new JButton(MessageConstantsUtil.getConstantValueByMemory("entityListPanel.text.removeBut")); entityListDbTableBut = new JButton(MessageConstantsUtil.getConstantValueByMemory("entityListPanel.text.dbTableBut")); // 设置位置 entityListPanel.setBounds(panelX, entityPanel.getY() + entityPanel.getHeight() + panelYDiff, panelWidth, 300 + labelYDiff); // 第一行 entityFieldFilterText.setBounds(labelX, labelY, 80, heigth); entityJavaModelFieldFilter.setBounds(entityFieldFilterText.getX() + entityFieldFilterText.getWidth() + labelXDiff, labelY, 100, heigth); entityJspConfigFieldFilter.setBounds(entityJavaModelFieldFilter.getX() + entityJavaModelFieldFilter.getWidth() + labelXDiff, labelY, 120, heigth); entityJspConfigFrozenFieldFilter.setBounds(entityJspConfigFieldFilter.getX() + entityJspConfigFieldFilter.getWidth() + labelXDiff, labelY, 100, heigth); entityJspQueryFieldFilter.setBounds(entityJspConfigFrozenFieldFilter.getX() + entityJspConfigFrozenFieldFilter.getWidth() + labelXDiff, labelY, 100, heigth); entityJspAddFieldFilter.setBounds(entityJspQueryFieldFilter.getX() + entityJspQueryFieldFilter.getWidth() + labelXDiff, labelY, 100, heigth); entityJspUpdateFieldFilter.setBounds(entityJspAddFieldFilter.getX() + entityJspAddFieldFilter.getWidth() + labelXDiff, labelY, 100, heigth); entityJspViewFieldFilter.setBounds(entityJspUpdateFieldFilter.getX() + entityJspUpdateFieldFilter.getWidth() + labelXDiff, labelY, 100, heigth); // 第二行 entityListAddBut.setBounds(labelX, entityFieldFilterText.getY() + labelYDiff, 100, heigth); entityListRemoveBut.setBounds(entityListAddBut.getX() + entityListAddBut.getWidth() + labelXDiff, entityFieldFilterText.getY() + labelYDiff, 100, heigth); entityListDbTableBut.setBounds(entityListRemoveBut.getX() + entityListRemoveBut.getWidth() + labelXDiff, entityFieldFilterText.getY() + labelYDiff, 130, heigth); // 第三行 entityListTableScroll.setBounds(labelX, entityListAddBut.getY() + labelYDiff, scrollWidth - 60, 240); logger.debug(MessageConstantsUtil.getConstantValueByMemory("entityListPanel.text.title") + "-位置设置完成"); // 添加控件 entityListPanel.add(entityFieldFilterText); entityListPanel.add(tip(entityJavaModelFieldFilter, "tip.entityPanel.text.filter.reversal")); entityListPanel.add(tip(entityJspConfigFieldFilter, "tip.entityPanel.text.filter.reversal")); entityListPanel.add(tip(entityJspConfigFrozenFieldFilter, "tip.entityPanel.text.filter.reversal")); entityListPanel.add(tip(entityJspQueryFieldFilter, "tip.entityPanel.text.filter.reversal")); entityListPanel.add(tip(entityJspAddFieldFilter, "tip.entityPanel.text.filter.reversal")); entityListPanel.add(tip(entityJspUpdateFieldFilter, "tip.entityPanel.text.filter.reversal")); entityListPanel.add(tip(entityJspViewFieldFilter, "tip.entityPanel.text.filter.reversal")); entityListPanel.add(entityListAddBut); entityListPanel.add(entityListRemoveBut); entityListPanel.add(entityListDbTableBut); entityListPanel.add(entityListTableScroll); logger.debug(MessageConstantsUtil.getConstantValueByMemory("entityListPanel.text.title") + "-控件添加完成"); } /** * 实例化基础信息控件 * * @author 张军 * @date 2015-11-03 21:59:00 * @modifiyNote * @version 1.0 */ private void createBasicPanel() { basicPanel = new JPanel(); // 第一行 // 包模块 basicModuleNameText = new JLabel(MessageConstantsUtil.getConstantValueByMemory("basicPanel.text.moduleName")); basicModuleName = new JTextField(); // src目录 basicSrcDirPathText = new JLabel(MessageConstantsUtil.getConstantValueByMemory("basicPanel.text.srcDirPath")); basicSrcDirPath = new JTextField(); basicSrcDirPathBut = new JButton(MessageConstantsUtil.getConstantValueByMemory("basicPanel.text.srcDirPathBut")); // webRoot目录 basicWebRootDirPathText = new JLabel(MessageConstantsUtil.getConstantValueByMemory("basicPanel.text.webRootDirPath")); basicWebRootDirPath = new JTextField(); basicWebRootDirPathBut = new JButton(MessageConstantsUtil.getConstantValueByMemory("basicPanel.text.webRootDirPathBut")); // 第二行 // 绝对路径 // JLabel basicAbsolutePathText = new JLabel(MessageConstantsUtil.getConstantValueByMemory("basicPanel.text.absolutePath")); basicAbsolutePathAble = new JCheckBox(MessageConstantsUtil.getConstantValueByMemory("basicPanel.text.absolutePath")); // 作者 basicAuthorText = new JLabel(MessageConstantsUtil.getConstantValueByMemory("basicPanel.text.author")); basicAuthor = new JTextField(); // 数据库表名 entityTableNameText = new JLabel(MessageConstantsUtil.getConstantValueByMemory("entityPanel.text.tableName")); entityTableName = new JTextField(); // 实体类名 entityEntityNameText = new JLabel(MessageConstantsUtil.getConstantValueByMemory("entityPanel.text.entityName")); entityEntityName = new JTextField(); // 描述信息 entityDescriptionText = new JLabel(MessageConstantsUtil.getConstantValueByMemory("entityPanel.text.description")); entityDescription = new JTextField(); // 设置位置 basicPanel.setBounds(panelX, dbPanel.getY() + dbPanel.getHeight() + panelYDiff, panelWidth, 60 + labelYDiff); // 第一行 basicModuleNameText.setBounds(labelX, labelY, 60, heigth); basicModuleName.setBounds(basicModuleNameText.getX() + basicModuleNameText.getWidth() + labelXDiff, labelY, 100, heigth); basicSrcDirPathText.setBounds(basicModuleName.getX() + basicModuleName.getWidth() + labelXDiff + labelXDiff2, labelY, 50, heigth); basicSrcDirPath.setBounds(basicSrcDirPathText.getX() + basicSrcDirPathText.getWidth() + labelXDiff, labelY, 230, heigth); basicSrcDirPathBut.setBounds(basicSrcDirPath.getX() + basicSrcDirPath.getWidth() + labelXDiff, labelY, 120, heigth); basicWebRootDirPathText.setBounds(basicSrcDirPathBut.getX() + basicSrcDirPathBut.getWidth() + labelXDiff + labelXDiff2, labelY, 80, heigth); basicWebRootDirPath.setBounds(basicWebRootDirPathText.getX() + basicWebRootDirPathText.getWidth() + labelXDiff, labelY, 230, heigth); basicWebRootDirPathBut.setBounds(basicWebRootDirPath.getX() + basicWebRootDirPath.getWidth() + labelXDiff, labelY, 140, heigth); // 第二行 // basicAbsolutePathText.setBounds(labelX, basicModuleNameText.getY() + labelYDiff, 180, heigth); // basicAbsolutePath.setBounds(basicAbsolutePathText.getX() + basicAbsolutePathText.getWidth() + labelXDiff, basicModuleNameText.getY() + labelYDiff, 50, heigth); // basicAuthorText.setBounds(basicAbsolutePath.getX() + basicAbsolutePath.getWidth() + labelXDiff + labelXDiff2, basicModuleNameText.getY() + labelYDiff, 40, heigth); basicAbsolutePathAble.setBounds(labelX, basicModuleNameText.getY() + labelYDiff, 80, heigth); basicAuthorText.setBounds(basicAbsolutePathAble.getX() + basicAbsolutePathAble.getWidth() + labelXDiff + labelXDiff2, basicModuleNameText.getY() + labelYDiff, 40, heigth); basicAuthor.setBounds(basicAuthorText.getX() + basicAuthorText.getWidth() + labelXDiff, basicModuleNameText.getY() + labelYDiff, 70, heigth); entityTableNameText.setBounds(basicAuthor.getX() + basicAuthor.getWidth() + labelXDiff, basicModuleNameText.getY() + labelYDiff, 80, heigth); entityTableName.setBounds(entityTableNameText.getX() + entityTableNameText.getWidth() + labelXDiff, basicModuleNameText.getY() + labelYDiff, 150, heigth); entityEntityNameText.setBounds(entityTableName.getX() + entityTableName.getWidth() + labelXDiff, basicModuleNameText.getY() + labelYDiff, 70, heigth); entityEntityName.setBounds(entityEntityNameText.getX() + entityEntityNameText.getWidth() + labelXDiff, basicModuleNameText.getY() + labelYDiff, 150, heigth); entityDescriptionText.setBounds(entityEntityName.getX() + entityEntityName.getWidth() + labelXDiff, basicModuleNameText.getY() + labelYDiff, 60, heigth); entityDescription.setBounds(entityDescriptionText.getX() + entityDescriptionText.getWidth() + labelXDiff, basicModuleNameText.getY() + labelYDiff, 300, heigth); logger.debug(MessageConstantsUtil.getConstantValueByMemory("basicPanel.text.title") + "-位置设置完成"); // 添加控件 // 第一行 basicPanel.add(basicModuleNameText); basicPanel.add(tip(basicModuleName, "tip.basicPanel.text.moduleName")); basicPanel.add(basicSrcDirPathText); basicPanel.add(tip(basicSrcDirPath, "tip.basicPanel.text.srcDirPath")); basicPanel.add(tip(basicSrcDirPathBut, "tip.basicPanel.text.srcDirPath")); basicPanel.add(basicWebRootDirPathText); basicPanel.add(tip(basicWebRootDirPath, "tip.basicPanel.text.webRootDirPath")); basicPanel.add(tip(basicWebRootDirPathBut, "tip.basicPanel.text.webRootDirPath")); // 第二行 // basicPanel.add(basicAbsolutePathText); // basicPanel.add(basicAbsolutePath); basicPanel.add(tip(basicAbsolutePathAble, "tip.basicPanel.text.absolutePath")); basicPanel.add(basicAuthorText); basicPanel.add(basicAuthor); basicPanel.add(entityTableNameText); basicPanel.add(entityTableName); basicPanel.add(entityEntityNameText); basicPanel.add(entityEntityName); basicPanel.add(entityDescriptionText); basicPanel.add(entityDescription); logger.debug(MessageConstantsUtil.getConstantValueByMemory("basicPanel.text.title") + "-控件添加完成"); } /** * 实例化数据库连接信息控件 * * @author 张军 * @date 2015-11-03 21:59:00 * @modifiyNote * @version 1.0 */ private void createDbPanel() { dbPanel = new JPanel(); // 第一行 // 驱动模型 dbTypeText = new JLabel(MessageConstantsUtil.getConstantValueByMemory("dbPanel.text.type")); // 用户名 dbUserNameText = new JLabel(MessageConstantsUtil.getConstantValueByMemory("dbPanel.text.userName")); dbUserName = new JTextField(); // 密码 dbPasswordText = new JLabel(MessageConstantsUtil.getConstantValueByMemory("dbPanel.text.password")); dbPassword = new JPasswordField(); // 连接地址 dbUrlText = new JLabel(MessageConstantsUtil.getConstantValueByMemory("dbPanel.text.url")); dbUrl = new JTextField(); // 第二行 // 是否创建菜单 dbMenuTableAble = new JCheckBox(MessageConstantsUtil.getConstantValueByMemory("dbPanel.text.menuTableAble")); dbMenuTable = new JTextField(); // 是否创建按钮 dbMenuButTableAbleText = new JLabel(MessageConstantsUtil.getConstantValueByMemory("dbPanel.text.menuButTableAble")); dbMenuButTableAdd = new JCheckBox(MessageConstantsUtil.getConstantValueByMemory("dbPanel.text.menuButTableAdd")); dbMenuButTableUpdate = new JCheckBox(MessageConstantsUtil.getConstantValueByMemory("dbPanel.text.menuButTableUpdate")); dbMenuButTableDel = new JCheckBox(MessageConstantsUtil.getConstantValueByMemory("dbPanel.text.menuButTableDel")); dbMenuButTableUndel = new JCheckBox(MessageConstantsUtil.getConstantValueByMemory("dbPanel.text.menuButTableUndel")); dbMenuButTableView = new JCheckBox(MessageConstantsUtil.getConstantValueByMemory("dbPanel.text.menuButTableView")); dbMenuButTable = new JTextField(); // 菜单按钮数据 dbDmlText = new JLabel(MessageConstantsUtil.getConstantValueByMemory("dbPanel.text.dml")); // 设置位置 dbPanel.setBounds(panelX, panelY, panelWidth, 60 + labelYDiff); // 第一行 dbTypeText.setBounds(labelX, labelY, 60, heigth); dbDriver.setBounds(dbTypeText.getX() + dbTypeText.getWidth() + labelXDiff, labelY, 100, heigth); dbUserNameText.setBounds(dbDriver.getX() + dbDriver.getWidth() + labelXDiff + labelXDiff2, labelY, 50, heigth); dbUserName.setBounds(dbUserNameText.getX() + dbUserNameText.getWidth() + labelXDiff, labelY, 150, heigth); dbPasswordText.setBounds(dbUserName.getX() + dbUserName.getWidth() + labelXDiff + labelXDiff2, labelY, 50, heigth); dbPassword.setBounds(dbPasswordText.getX() + dbPasswordText.getWidth() + labelXDiff, labelY, 150, heigth); dbUrlText.setBounds(dbPassword.getX() + dbPassword.getWidth() + labelXDiff + labelXDiff2, labelY, 60, heigth); dbUrl.setBounds(dbUrlText.getX() + dbUrlText.getWidth() + labelXDiff, labelY, 350, heigth); // 第二行 dbMenuTableAble.setBounds(labelX, dbTypeText.getY() + labelYDiff, 80, heigth); dbMenuTable.setBounds(dbMenuTableAble.getX() + dbMenuTableAble.getWidth(), dbTypeText.getY() + labelYDiff, 120, heigth); dbMenuButTableAbleText.setBounds(dbMenuTable.getX() + dbMenuTable.getWidth() + labelXDiff + labelXDiff2, dbTypeText.getY() + labelYDiff, 60, heigth); dbMenuButTableAdd.setBounds(dbMenuButTableAbleText.getX() + dbMenuButTableAbleText.getWidth() + labelXDiff, dbTypeText.getY() + labelYDiff, 60, heigth); dbMenuButTableUpdate.setBounds(dbMenuButTableAdd.getX() + dbMenuButTableAdd.getWidth() + labelXDiff, dbTypeText.getY() + labelYDiff, 60, heigth); dbMenuButTableDel.setBounds(dbMenuButTableUpdate.getX() + dbMenuButTableUpdate.getWidth() + labelXDiff, dbTypeText.getY() + labelYDiff, 60, heigth); dbMenuButTableUndel.setBounds(dbMenuButTableDel.getX() + dbMenuButTableDel.getWidth() + labelXDiff, dbTypeText.getY() + labelYDiff, 80, heigth); dbMenuButTableView.setBounds(dbMenuButTableUndel.getX() + dbMenuButTableUndel.getWidth() + labelXDiff, dbTypeText.getY() + labelYDiff, 60, heigth); dbMenuButTable.setBounds(dbMenuButTableView.getX() + dbMenuButTableView.getWidth(), dbTypeText.getY() + labelYDiff, 120, heigth); dbDmlText.setBounds(dbMenuButTable.getX() + dbMenuButTable.getWidth() + labelXDiff + labelXDiff2, dbTypeText.getY() + labelYDiff, 120, heigth); dbDml.setBounds(dbDmlText.getX() + dbDmlText.getWidth(), dbTypeText.getY() + labelYDiff, 120, heigth); logger.debug(MessageConstantsUtil.getConstantValueByMemory("dbPanel.text.title") + "-位置设置完成"); // 添加控件 // 第一行 dbPanel.add(dbTypeText); dbPanel.add(dbDriver); dbPanel.add(dbUserNameText); dbPanel.add(dbUserName); dbPanel.add(dbPasswordText); dbPanel.add(dbPassword); dbPanel.add(dbUrlText); dbPanel.add(dbUrl); // 第二行 dbPanel.add(dbMenuTableAble); dbPanel.add(tip(dbMenuTable, "tip.dbPanel.text.menuTable")); dbPanel.add(dbMenuButTableAbleText); dbPanel.add(tip(dbMenuButTableAdd, "tip.dbPanel.text.menuBut")); dbPanel.add(tip(dbMenuButTableUpdate, "tip.dbPanel.text.menuBut")); dbPanel.add(tip(dbMenuButTableDel, "tip.dbPanel.text.menuBut")); dbPanel.add(tip(dbMenuButTableUndel, "tip.dbPanel.text.menuBut")); dbPanel.add(tip(dbMenuButTableView, "tip.dbPanel.text.menuBut")); dbPanel.add(tip(dbMenuButTable, "tip.dbPanel.text.menuButTable")); dbPanel.add(dbDmlText); dbPanel.add(dbDml); logger.debug(MessageConstantsUtil.getConstantValueByMemory("dbPanel.text.title") + "-控件添加完成"); } /** * 实例化菜单 * * @author 张军 * @date 2015-11-03 21:59:00 * @modifiyNote * @version 1.0 */ private void createMenuBar() { jMenuBar = new JMenuBar(); jFile = new JMenu(MessageConstantsUtil.getConstantValueByMemory("jMenuBar.text.jFile")); jOpenFile = new JMenuItem(MessageConstantsUtil.getConstantValueByMemory("jMenuBar.text.jOpenFile")); jSaveFile = new JMenuItem(MessageConstantsUtil.getConstantValueByMemory("jMenuBar.text.jSaveFile")); jFileAuthor = new JMenu("关于"); jContactFile = new JMenuItem("联系管理员"); // 添加控件 jFile.add(jOpenFile); // ImageIcon folderopen = new ImageIcon("E:/versionManager/sources/java/zj-model/integration/runnable-generate-code/src/main/sources/ftl/Book_openHS.bmp"); // 这里定义一个Icon图片 // jFile.setIcon(folderopen); jFile.add(jSaveFile); jFileAuthor.add(jContactFile); jMenuBar.add(jFile); jMenuBar.add(jFileAuthor); logger.debug(MessageConstantsUtil.getConstantValueByMemory("scrollPanel.text.title") + "-控件添加完成"); } /** * 设置下拉框值 * * @author 张军 * @date 2015-11-03 21:59:00 * @modifiyNote * @version 1.0 */ private void setComboxItems() { Vector<ComboxItem> model = null; // 驱动模板 model = new Vector<ComboxItem>(); dbDriverDefault = new ComboxItem("", MessageConstantsUtil.getConstantValueByMemory("select.text.default")); dbDriverOracle = new ComboxItem(JdbcUtil.DB_TYPE_ORACLE, JdbcUtil.DB_TYPE_ORACLE); dbDriverMysql = new ComboxItem(JdbcUtil.DB_TYPE_MYSQL, JdbcUtil.DB_TYPE_MYSQL); model.addElement(dbDriverDefault); model.addElement(dbDriverOracle); model.addElement(dbDriverMysql); // model.addElement(new ComboxItem(JdbcUtil.DB_TYPE_INFORMIX, JdbcUtil.DB_TYPE_INFORMIX)); // model.addElement(new ComboxItem(JdbcUtil.DB_TYPE_DB2, JdbcUtil.DB_TYPE_DB2)); dbDriver = new JComboBox(model); // 绝对路径 // selectedAbsolutePath = new ComboxItem(MessageConstantsUtil.getConstantValueByMemory("select.text.n"), MessageConstantsUtil.getConstantValueByMemory("select.text.n")); // model = new Vector<ComboxItem>(); // model.addElement(new ComboxItem(MessageConstantsUtil.getConstantValueByMemory("select.text.y"), MessageConstantsUtil.getConstantValueByMemory("select.text.y"))); // model.addElement(selectedAbsolutePath); // basicAbsolutePath = new JComboBox(model); // 菜单按钮数据 model = new Vector<ComboxItem>(); selectedDml = new ComboxItem(MessageConstantsUtil.getConstantValueByMemory("select.text.none"), MessageConstantsUtil.getConstantValueByMemory("select.text.none")); dbDmlSaveOrUpdate = new ComboxItem(MessageConstantsUtil.getConstantValueByMemory("select.text.saveOrUpdate"), MessageConstantsUtil.getConstantValueByMemory("select.text.saveOrUpdate")); dbDmlDelete = new ComboxItem(MessageConstantsUtil.getConstantValueByMemory("select.text.delete"), MessageConstantsUtil.getConstantValueByMemory("select.text.delete")); model.addElement(dbDmlSaveOrUpdate); model.addElement(dbDmlDelete); model.addElement(selectedDml); dbDml = new JComboBox(model); // 默认打开方式 // 添加页面 model = new Vector<ComboxItem>(); selectedOpenTypeDefault = new ComboxItem(MessageConstantsUtil.getConstantValueByMemory("select.text.pageBlock"), MessageConstantsUtil.getConstantValueByMemory("select.text.pageBlock")); entityJspAddOpenTypeDialog = new ComboxItem(MessageConstantsUtil.getConstantValueByMemory("select.text.dialog"), MessageConstantsUtil.getConstantValueByMemory("select.text.dialog")); model.addElement(entityJspAddOpenTypeDialog); model.addElement(selectedOpenTypeDefault); entityJspAddOpenType = new JComboBox(model); // 更新页面 model = new Vector<ComboxItem>(); entityJspUpdateOpenTypeDialog = new ComboxItem(MessageConstantsUtil.getConstantValueByMemory("select.text.dialog"), MessageConstantsUtil.getConstantValueByMemory("select.text.dialog")); model.addElement(entityJspUpdateOpenTypeDialog); model.addElement(selectedOpenTypeDefault); entityJspUpdateOpenType = new JComboBox(model); // 查看页面 model = new Vector<ComboxItem>(); entityJspViewOpenTypeDialog = new ComboxItem(MessageConstantsUtil.getConstantValueByMemory("select.text.dialog"), MessageConstantsUtil.getConstantValueByMemory("select.text.dialog")); model.addElement(entityJspViewOpenTypeDialog); model.addElement(selectedOpenTypeDefault); entityJspViewOpenType = new JComboBox(model); // 查看(列表)页面 model = new Vector<ComboxItem>(); selectedJspConfigFieldViewDetail = new ComboxItem(MessageConstantsUtil.getConstantValueByMemory("select.text.n"), MessageConstantsUtil.getConstantValueByMemory("select.text.n")); entityJspConfigFieldViewDetailY = new ComboxItem(MessageConstantsUtil.getConstantValueByMemory("select.text.y"), MessageConstantsUtil.getConstantValueByMemory("select.text.y")); model.addElement(entityJspConfigFieldViewDetailY); model.addElement(selectedJspConfigFieldViewDetail); entityJspConfigFieldViewDetail = new JComboBox(model); // 数据删除类型 model = new Vector<ComboxItem>(); selectedDeleteType = new ComboxItem(MessageConstantsUtil.getConstantValueByMemory("select.text.logicDelete"), MessageConstantsUtil.getConstantValueByMemory("select.text.logicDelete")); entityDeleteTypePhysicalDelete = new ComboxItem(MessageConstantsUtil.getConstantValueByMemory("select.text.physicalDelete"), MessageConstantsUtil.getConstantValueByMemory("select.text.physicalDelete")); model.addElement(entityDeleteTypePhysicalDelete); model.addElement(selectedDeleteType); entityDeleteType = new JComboBox(model); // 数据库中表中的列类型 entityListJdbcTypes = new JComboBox(ARY_JDBC_TYPES); // java类型 entityListJavaTypes = new JComboBox(ARY_JAVA_TYPES); // 操作类型 model = new Vector<ComboxItem>(); selectedOperatorType = new ComboxItem(MessageConstantsUtil.getConstantValueByMemory("select.text.operateCreate"), MessageConstantsUtil.getConstantValueByMemory("select.text.operateCreate")); operatorTypeY = new ComboxItem(MessageConstantsUtil.getConstantValueByMemory("select.text.operateDelete"), MessageConstantsUtil.getConstantValueByMemory("select.text.operateDelete")); model.addElement(selectedOperatorType); model.addElement(operatorTypeY); operatorType = new JComboBox(model); } /** * 关闭窗口 * * @author 张军 * @date 2015-11-03 21:59:00 * @modifiyNote * @version 1.0 */ public void addEventHandler() { jframe.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { exitConfirm(); } }); } /** * 退出程序 */ private void exitConfirm() { int op = JOptionPane.showConfirmDialog(jframe, MessageConstantsUtil.getConstantValueByMemory("other.text.exitConfirm"), MessageConstantsUtil.getConstantValueByMemory("other.text.prompt"), JOptionPane.YES_NO_OPTION); if (op == JOptionPane.YES_OPTION) { System.exit(0); } } /** 显示菜单 **/ public void showMe() { jframe.setSize(frameWidth, frameHeight); jframe.setLocation(10, 10); jframe.setVisible(true); // jframe.setResizable(false); jframe.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); jframe.setAlwaysOnTop(false); } }
如需要获取源码,请先 登录
本文为张军原创文章,转载无需和我联系,但请注明来自张军的军军小站,个人博客http://www.zhangjunbk.com