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

📄 gui.java

📁 人力资源管理系统主要包括:人员管理、招聘管理、培训管理、奖惩管理和薪金管理五大管理模块。
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
		// Add your handling code here:		int[] selected = selectedTables.getSelectedIndices();		cmdGenerate.setEnabled(!(selected == null || selected.length == 0));	}//GEN-LAST:event_selectedTablesValueChanged		private void optionTableMapItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_optionTableMapItemStateChanged		// Add your handling code here:		mappingFile.setEnabled(!optionTableMap.isSelected());	}//GEN-LAST:event_optionTableMapItemStateChanged		private void generatorNameItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_generatorNameItemStateChanged		// Add your handling code here:		if (generatorName.getSelectedIndex() != -1) {			String gName = (String)generatorName.getSelectedItem();			if (				gName.equals("vm.long") ||				gName.equals("native") ||				gName.equals("sequence") ||				gName.equals("hilo.long") ||				gName.equals("seqhilo.long")			) {				keyFieldType.setSelectedIndex(LONG_TYPE);			}			else if (				gName.equals("uuid.hex") ||				gName.equals("uuid.string") ||				gName.equals("vm.hex") ||				gName.equals("hilo.hex")			) {				keyFieldType.setSelectedIndex(STRING_TYPE);			}		}	}//GEN-LAST:event_generatorNameItemStateChanged		private void cmdParamsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdParamsActionPerformed		// Add your handling code here:		ParamsPanel paramsPanel = new ParamsPanel();		if (generationParameters != null) paramsPanel.setParameters(generationParameters);		int choice =JOptionPane.showConfirmDialog(this, paramsPanel, "Generation Parameters", JOptionPane.OK_CANCEL_OPTION);		if (choice == JOptionPane.OK_OPTION) {			this.generationParameters = paramsPanel.getParameters();		}	}//GEN-LAST:event_cmdParamsActionPerformed		private void cmdGenerateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdGenerateActionPerformed		// Add your handling code here:		Connection connection=null;		try {			MapGenerator mg = new MapGenerator();			String cat = (String)catalogName.getSelectedItem();			if (cat != null && cat.length() > 0) mg.setCatalog(cat);			String schem = (String)schemaName.getSelectedItem();			if (schem != null && schem.length() > 0) mg.setSchemaPattern(schem);						Object[] otables = selectedTables.getSelectedValues();			if (otables != null && otables.length > 0) {				String[] tables = (String[])Arrays.asList(otables).toArray(new String[0]);				mg.setTableNames(tables);			}			String pack = packageName.getText();			if (pack != null && pack.length() > 0) mg.setPackageName(pack);			String dir = outputDirectory.getText();			if (dir != null && dir.length() > 0) mg.setOutputDirectory(new File(dir));			String id = idFieldName.getText();			if (id != null && id.length() > 0) mg.setIdName(id);			String idType = (String)keyFieldType.getSelectedItem();			if (idType != null && idType.length() > 0) mg.setIdType(idType);			String baseClassName = (String)baseClass.getText();			if (baseClassName != null && baseClassName.length() > 0) mg.setBaseClass(baseClassName);			mg.setHibernateTypes(optionHibernateTypes.isSelected());						String generator = (String)generatorName.getSelectedItem();			if (generator != null) {				mg.setGenerator(generator);				if (generationParameters != null) {					mg.setGeneratorParameters(generationParameters);				}			}						mg.setSingleMapFile(optionSingleMap.isSelected());			if (this.optionSingleMap.isSelected()) {				mg.setMappingFile(mappingFile.getText());			}						connection = getConnection();			mg.generate(connection);		}		catch (Exception e) {			JOptionPane.showMessageDialog(this, e);			e.printStackTrace();		}		finally {			if (connection != null) {				try {					connection.close();				}				catch (Exception e) {}			}		}			}//GEN-LAST:event_cmdGenerateActionPerformed		private void cmdPickDirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmdPickDirActionPerformed		// Add your handling code here:		JFileChooser jfc = new JFileChooser();		jfc.setDialogTitle("Choose an output directory");		jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);		String outputDir = outputDirectory.getText();		if (outputDir != null && outputDir.length() > 0) {			jfc.setCurrentDirectory(new File(outputDir));		}		int returnVal = jfc.showOpenDialog(this);		if(returnVal == JFileChooser.APPROVE_OPTION) {			this.outputDirectory.setText(jfc.getSelectedFile().getAbsolutePath());		}			}//GEN-LAST:event_cmdPickDirActionPerformed					// Variables declaration - do not modify//GEN-BEGIN:variables	private javax.swing.JRadioButton optionSingleMap;	private javax.swing.JComboBox generatorName;	private javax.swing.JTextField tableName;	private javax.swing.JTextField packageName;	private javax.swing.JTextField outputDirectory;	private javax.swing.JPanel cmdPanel;	private javax.swing.JTextField mappingFile;	private javax.swing.JTextField dbUser;	private javax.swing.ButtonGroup buttonGroup1;	private javax.swing.JList selectedTables;	private javax.swing.JButton cmdParams;	private javax.swing.JPanel tableListHolder;	private javax.swing.JPanel mappingPanel;	private javax.swing.JButton cmdGenerate;	private javax.swing.JLabel jLabel9;	private javax.swing.JLabel jLabel8;	private javax.swing.JLabel jLabel7;	private javax.swing.JLabel jLabel14;	private javax.swing.JLabel jLabel13;	private javax.swing.JComboBox schemaName;	private javax.swing.JLabel jLabel6;	private javax.swing.JLabel jLabel5;	private javax.swing.JLabel jLabel12;	private javax.swing.ButtonGroup keyFieldTypeGroup;	private javax.swing.JLabel jLabel11;	private javax.swing.JTextField idFieldName;	private javax.swing.JLabel jLabel4;	private javax.swing.JPanel databasePanel;	private javax.swing.JLabel jLabel3;	private javax.swing.JLabel jLabel10;	private javax.swing.JLabel jLabel2;	private javax.swing.JLabel jLabel1;	private javax.swing.JPanel connectionPanel;	private javax.swing.JComboBox catalogName;	private javax.swing.JRadioButton optionTableMap;	private javax.swing.JButton cmdGetTables;	private javax.swing.JScrollPane tablesScroller;	private javax.swing.JPanel mappingTypePanel;	private javax.swing.JPanel jPanel5;	private javax.swing.JPasswordField dbPassword;	private javax.swing.ButtonGroup mappingTypeGroup;	private javax.swing.JPanel jPanel1;	private javax.swing.JComboBox keyFieldType;	private javax.swing.JLabel Generator;	private javax.swing.JTextField connectionUrl;	private javax.swing.JTextField driverClass;	private javax.swing.JTextField baseClass;	private javax.swing.JPanel tablesPanel;	private javax.swing.JRadioButton optionHibernateTypes;	private javax.swing.JTabbedPane tabbedPanel;	private javax.swing.JPanel codePanel;	private javax.swing.JPanel genPanel;	private javax.swing.JButton cmdPickDir;	private javax.swing.JPanel outputPanel;	private javax.swing.JRadioButton optionJavaTypes;	// End of variables declaration//GEN-END:variables		public static void main(String[] args) throws Exception {		JFrame frame = new JFrame("Hibernate Mapping SchemaExport");		try {			Gui applet = (Gui)java.beans.Beans.instantiate(Gui.class.getClassLoader(), Gui.class.getName());			frame.getContentPane().add(applet);			frame.pack();			frame.setResizable(true);						java.awt.Dimension screenDim = java.awt.Toolkit.getDefaultToolkit().getScreenSize();			java.awt.Dimension frameDim = frame.getSize();			java.awt.Point frameCenter = new java.awt.Point(				(int)(screenDim.getWidth()-frameDim.getWidth())/2,				(int)(screenDim.getHeight()-frameDim.getHeight())/2			);			frame.setLocation(frameCenter);						frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);			frame.show();		}		catch (Exception e) {			JOptionPane.showConfirmDialog(frame, e);		}	}			protected Connection getConnection() throws SQLException, ClassNotFoundException {		Class.forName(driverClass.getText());		return DriverManager.getConnection(			connectionUrl.getText(),			dbUser.getText(),			new String(dbPassword.getPassword())		);	}		protected void saveState() {		Properties p = new Properties();		//p.put("catalogName", catalogName.getText());		//p.put("schemaName", schemaName.getText());		//p.put("tableName", tableName.getText());		p.put("driverClass", driverClass.getText());		p.put("connectionUrl", connectionUrl.getText());		p.put("dbUser", dbUser.getText());				p.put("tableName", tableName.getText());				p.put("singleMapType", StringHelper.EMPTY_STRING + optionSingleMap.isSelected());		p.put("mapName", mappingFile.getText());		p.put("generatorName", generatorName.getSelectedItem());		if (this.generationParameters != null) {			String gp=StringHelper.EMPTY_STRING;			for (int i=0; i < generationParameters.length; i++) {				gp += generationParameters[i] + "\t";			}			p.put("generatorParameters", gp);		}		p.put("keyFieldName", idFieldName.getText());		p.put("keyFieldType", keyFieldType.getSelectedItem());		p.put("useHibernateTypes", StringHelper.EMPTY_STRING + optionHibernateTypes.isSelected());		p.put("packageName", packageName.getText());		p.put("baseClass", baseClass.getText());				p.put("outputDirectory", outputDirectory.getText());				File propsFile = new File(System.getProperty("user.home"), "mapgen.properties");		try {			FileOutputStream fos = new FileOutputStream(propsFile);			try{				p.store(fos, "SchemaExport");			}			finally {				fos.close();			}		}		catch (IOException ioe) {		}			}		protected void readState() {		File propsFile = new File(System.getProperty("user.home"), "mapgen.properties");		Properties p = new Properties();		try {			FileInputStream fis = new FileInputStream(propsFile);			try{				p.load(fis);								driverClass.setText(p.getProperty("driverClass"));				connectionUrl.setText(p.getProperty("connectionUrl"));				dbUser.setText(p.getProperty("dbUser"));								//catalogName.setText(p.getProperty("catalogName"));				//schemaName.setSelectedItem(p.getProperty("schemaName"));				tableName.setText(p.getProperty("tableName"));								String mapType = p.getProperty("singleMapType");				if (p.getProperty("mapName") != null) mappingFile.setText(p.getProperty("mapName"));				optionSingleMap.setSelected(mapType != null && mapType.equals("true"));				generatorName.setSelectedItem(p.getProperty("generatorName"));				if (p.getProperty("keyFieldName") != null) idFieldName.setText(p.getProperty("keyFieldName"));				keyFieldType.setSelectedItem(p.getProperty("keyFieldType"));				String useHibernateTypes =  p.getProperty("useHibernateTypes");				optionJavaTypes.setSelected(useHibernateTypes != null && useHibernateTypes.equals("false"));								packageName.setText(p.getProperty("packageName"));				baseClass.setText(p.getProperty("baseClass"));								if (p.getProperty("outputDirectory") != null) outputDirectory.setText(p.getProperty("outputDirectory"));								String gp = p.getProperty("generatorParameters");				if (gp != null) {					StringTokenizer st = new StringTokenizer(gp, "\t");					generationParameters = new String[st.countTokens()];					for (int i=0; i < generationParameters.length; i++) {						generationParameters[i] = st.nextToken();					}				}			}			finally {				fis.close();			}		}		catch (IOException ioe) {}	}}

⌨️ 快捷键说明

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