⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainframe.java

📁 TestDataBuilder是一个采用Java编写的
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
			
		}
	}


	/**
	 * This method initializes cbxOnError	
	 * 	
	 * @return javax.swing.JComboBox	
	 */
	private JComboBox getCbxOnError() {
		if (cbxOnError == null) {
			cbxOnError = new JComboBox();
			cbxOnError.setBounds(new Rectangle(322, 43, 173, 22));
			cbxOnError.addItem("ignore"); //$NON-NLS-1$
			cbxOnError.addItem("exit"); //$NON-NLS-1$
			cbxOnError.addItem("query"); //$NON-NLS-1$
		}
		return cbxOnError;
	}


	/**
	 * This method initializes initPanel	
	 * 	
	 * @return javax.swing.JScrollPane	
	 */
	private JScrollPane getInitPanel() {
		if (initPanel == null) {
			initPanel = new JScrollPane();
			initPanel.setBounds(new Rectangle(88, 73, 409, 53));
			initPanel.setViewportView(getTxtInit());
		}
		return initPanel;
	}


	/**
	 * This method initializes txtInit	
	 * 	
	 * @return javax.swing.JTextArea	
	 */
	private JTextArea getTxtInit() {
		if (txtInit == null) {
			txtInit = new JTextArea();
		}
		return txtInit;
	}


	/**
	 * This method initializes destroyPane	
	 * 	
	 * @return javax.swing.JScrollPane	
	 */
	private JScrollPane getDestroyPane() {
		if (destroyPane == null) {
			destroyPane = new JScrollPane();
			destroyPane.setBounds(new Rectangle(88, 136, 409, 53));
			destroyPane.setViewportView(getTxtDestroy());
		}
		return destroyPane;
	}


	/**
	 * This method initializes txtDestroy	
	 * 	
	 * @return javax.swing.JTextArea	
	 */
	private JTextArea getTxtDestroy() {
		if (txtDestroy == null) {
			txtDestroy = new JTextArea();
		}
		return txtDestroy;
	}


	/**
	 * This method initializes columnPane	
	 * 	
	 * @return javax.swing.JScrollPane	
	 */
	private JScrollPane getColumnPane() {
		if (columnPane == null) {
			columnPane = new JScrollPane();
			columnPane.setBounds(new Rectangle(88, 205, 409, 200));
			columnPane.setViewportView(getColumnTable());
		}
		return columnPane;
	}


	/**
	 * This method initializes columnTable	
	 * 	
	 * @return javax.swing.JTable	
	 */
	private ColumnTable getColumnTable() {
		if (columnTable == null) {
			columnTable = new ColumnTable();
			columnTable.addMouseListener(new java.awt.event.MouseAdapter() {
				public void mouseClicked(java.awt.event.MouseEvent e) {
					if(columnTable.getSelectedColumn() == 2 && e.getButton() == 1){
						MainFrame.this.editRole();
					}
				}
			});
			columnTable.setCellEditor(getTableCellEditor());
			
		}
		return columnTable;
	}
	

	protected void editRole() {
		int selRow = this.getColumnTable().getSelectedRow();
		String selRoleName = null;
		if(selRow != -1){
			ColumnConfig columnConfig = this.getColumnTable().getData().get(selRow);
			selRoleName = columnConfig.getRefRoleName();
		}
		showRoleDialogAndSelPath(this.getCurSelTable().getTableName(),
				selRoleName);
	}

	public DefaultCellEditor getTableCellEditor(){		
		JComboBox cbxTT = new JComboBox();
		cbxTT.addItem("String"); //$NON-NLS-1$
		cbxTT.addItem("def"); //$NON-NLS-1$
		DefaultCellEditor cellEditor = new DefaultCellEditor(cbxTT);
		
		return cellEditor;
	}



	/**
	 * This method initializes cbxCloseIDAutoInsert	
	 * 	
	 * @return javax.swing.JCheckBox	
	 */
	private JCheckBox getCbxCloseIDAutoInsert() {
		if (cbxCloseIDAutoInsert == null) {
			cbxCloseIDAutoInsert = new JCheckBox();
			cbxCloseIDAutoInsert.setBounds(new Rectangle(248, 19, 223, 13));
			cbxCloseIDAutoInsert.setText(RM.R("label.MainFrame.idEntityCanInsert")); //$NON-NLS-1$
		}
		return cbxCloseIDAutoInsert;
	}

	/**
	 * This method initializes btnAutoAnalyse	
	 * 	
	 * @return com.testDataBuilder.ui.core.JTDButton	
	 */
	private JTDButton getBtnAutoConfig() {
		if (btnAutoConfig == null) {
			btnAutoConfig = new JTDButton();
			btnAutoConfig.setBounds(new Rectangle(15, 301, 61, 23));
			btnAutoConfig.setText(RM.R("label.MainFrame.Auto")); //$NON-NLS-1$
			btnAutoConfig.setToolTipText(RM.R("label.MainFrame.auto.toolTip")); //$NON-NLS-1$
			btnAutoConfig.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					try {
						MainFrame.this.autoConfig();
					} catch (Exception e1) {
						logger.error("getBtnAutoConfig", e1); //$NON-NLS-1$
						JOptionPane.showMessageDialog(MainFrame.this, RM.R("label.MainFrame.error.saveResult") + e1.getMessage()); //$NON-NLS-1$
					} 
				}
			});
		}
		return btnAutoConfig;
	}


    public void autoConfig() throws SAXException, IOException, DocumentException{        
        Table table = this.getCurSelTable();
        if(table != null){
             AutoConfigEngine autoConfigEngine = new AutoConfigEngine();
             TableConfig tableConfig = autoConfigEngine.reverseTable(table);
             dataExchange(tableConfig, true);
             this.getWorkspaceDataCache().addOrRefershTableConfig(tableConfig);
             resetRefValues();
        }
    }
	/**
	 * This method initializes btnAdd	
	 * 	
	 * @return com.testDataBuilder.ui.core.JTDButton	
	 */
	private JTDButton getBtnAdd() {
		if (btnAdd == null) {
			btnAdd = new JTDButton();
			btnAdd.setBounds(new Rectangle(15, 234, 61, 23));
			btnAdd.setText(RM.R("label.MainFrame.add")); //$NON-NLS-1$
			btnAdd.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					MainFrame.this.addRow();
				}
			});
		}
		return btnAdd;
	}


	protected void addRow() {
		this.getColumnTable().addRow();
	}


	/**
	 * This method initializes btnDel	
	 * 	
	 * @return com.testDataBuilder.ui.core.JTDButton	
	 */
	private JTDButton getBtnDel() {
		if (btnDel == null) {
			btnDel = new JTDButton();
			btnDel.setBounds(new Rectangle(15, 268, 61, 23));
			btnDel.setText(RM.R("label.MainFrame.delete")); //$NON-NLS-1$
			btnDel.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					MainFrame.this.deleteCurrentItem();
				}
			});
		}
		return btnDel;
	}


	protected void deleteCurrentItem() {
		if(this.getColumnTable().getSelectedRow() != -1){
			int result = JOptionPane.showConfirmDialog(this, RM.R("label.MainFrame.delete.confirm")); //$NON-NLS-1$
			if(result == JOptionPane.OK_OPTION){
				this.getColumnTable().deleteCurrentItem();
			}
		}
	}


	/**
	 * This method initializes btnSave	
	 * 	
	 * @return com.testDataBuilder.ui.core.JTDButton	
	 */
	private JTDButton getBtnSave() {
		if (btnSave == null) {
			btnSave = new JTDButton();
			btnSave.setBounds(new Rectangle(298, 419, 92, 23));
			btnSave.setText(RM.R("label.MainFrame.SaveConfig")); //$NON-NLS-1$
			btnSave.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					try {
						MainFrame.this.saveConfig(e);
					} catch (IOException e1) {
						logger.error("getBtnSave", e1); //$NON-NLS-1$
						JOptionPane.showMessageDialog(MainFrame.this, "保存配置文件时出错! [" + e1.getMessage()); //$NON-NLS-1$
					}
				}
			});
		}
		return btnSave;
	}


	protected void saveConfig(java.awt.event.ActionEvent e) throws IOException {
		if(this.getCurSelTable() != null){
			TableConfig tableConfig = this.getCurTableConfig();
			if(tableConfig == null){
				tableConfig = new TableConfig();
			}
			this.dataExchange(tableConfig, false);
			tableConfig.saveConfig();
		}
	}


	/**
     * This method initializes btnCancel	
     * 	
     * @return com.testDataBuilder.ui.core.JTDButton	
     */
    private JTDButton getBtnClose() {
        if (btnClose == null) {
            btnClose = new JTDButton();
            btnClose.setBounds(new Rectangle(403, 419, 92, 23));
            btnClose.setText(RM.R("label.info.btnClose")); //$NON-NLS-1$
            btnClose.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent e) {
                    MainFrame.this.dispose();
                    System.exit(0);
                }
            });
        }
        return btnClose;
    }

    /**
	 * This method initializes jTabbedPane	
	 * 	
	 * @return javax.swing.JTabbedPane	
	 */
	private JTabbedPane getJTabbedPane() {
		if (jTabbedPane == null) {
			jTabbedPane = new JTabbedPane();
			jTabbedPane.addTab(RM.R("label.MainFrame.TestDataConfig.title"), this.getConfigPanel()); //$NON-NLS-1$
			jTabbedPane.addTab(RM.R("label.MainFrame.queryPane.title"), getQueryPane()); //$NON-NLS-1$
//			jTabbedPane.addTab(RM.R("label.MainFrame.dataModelPane.title"), getDataModelPanel());
            
            jTabbedPane.addChangeListener(new ChangeListener(){
                public void stateChanged(ChangeEvent e) {
                    MainFrame.this.tabbedPaneSelChanged();
                }
                
            });
		}
		return jTabbedPane;
	}

    public void tabbedPaneSelChanged() {
        int selIndex = this.getJTabbedPane().getSelectedIndex();
        switch(selIndex){
        case 0:
            
            break;
        case 1:
            if(StringUtils.isNotEmpty(getWorkspace())){
                //open default connection.                
                this.getQueryPane().initConnectionCombox(this.getTestDataConfig().getAllConnNames());
            }
                
            break;
        default:
                
        }
    }

    public QueryPanel getQueryPane(){
        if(queryPanel == null){
            queryPanel = new QueryPanel();
        }
        return queryPanel;
    }

	/**
	 * This is the default constructor
	 */
	private MainFrame() {        
		super();
		initialize();
		center();
		enableControl(false); 
	}

    private static MainFrame instance = null;
    
    public synchronized static MainFrame getInstance(){
        if(instance == null){
            instance = new MainFrame();
        }
        return instance;
    }

    private String initTitle = "TestDataBuilder"; //$NON-NLS-1$
    
	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
        G.initlize();
		this.setSize(750, 550);
		this.setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/resources/icon/TDB.png"))); //$NON-NLS-1$
        //this.setFont(new Font("宋体", Font.PLAIN, 10)); //$NON-NLS-1$
        this.setContentPane(getJContentPane());
		this.setJMenuBar(new JTDBMenuBar(this));
		this.setTitle(initTitle);
        Helper.getInstance().enableHelpKey(this.getRootPane(), "quickStart.readme"); //$NON-NLS-1$
    }


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -