package editorstudent.editors;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorSite;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.part.EditorPart;
import dbconnection.DBConnection;
import entity.Content;
import entity.Student;
public class MyEditor extends EditorPart {
public static final String ID ="editorstudent.editors.MyEditor";
private Text text1;
private Text text2;
private Text text3;
private Text text4;
private Text text5;
private Text text6;
public MyEditor() {
// TODO Auto-generated constructor stub
}
@Override
public void doSave(IProgressMonitor monitor) {
// TODO Auto-generated method stub
}
@Override
public void doSaveAs() {
// TODO Auto-generated method stub
}
@Override
public void init(IEditorSite site, IEditorInput input)
throws PartInitException {
// TODO Auto-generated method stub
setSite(site);
setInput(input);
setPartName(input.getName());
}
@Override
public boolean isDirty() {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isSaveAsAllowed() {
// TODO Auto-generated method stub
return false;
}
@Override
public void createPartControl(Composite parent) {
// TODO Auto-generated method stub
Composite container = new Composite(parent, SWT.BORDER);
String strNo = null;
String name = null;
String gender = null;
int age = 0;
String nativePlace = null;
String profession = null;
String stuNo = this.getTitle();
String select = "select * from student where stu_no = '" + stuNo + "'";
Connection conn = null;
Statement stmt = null;
try{
conn = DBConnection.getConnection();
stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(select);
rs.next();
strNo = rs.getString(1);
name = rs.getString(2);
gender = rs.getString(3);
age = rs.getInt(4);
nativePlace = rs.getString(5);
profession = rs.getString(6);
}catch(SQLException e){
e.printStackTrace();
}
/*
GridLayout layout = new GridLayout();
layout.numColumns = 2;
parent.setLayout(layout);
Label label1 = new Label(container, SWT.NONE);
label1.setText("学号:");
label1.setBounds(10, 10, 100, 100);
Text text1 = new Text(container, SWT.BORDER);
text1.setText(strNo);
text1.setSize(100,30);
Label label2 = new Label(parent, SWT.BORDER);
label2.setText("姓名:");
Text text2 = new Text(container, SWT.BORDER);
text2.setText(name);
Label label3 = new Label(parent, SWT.BORDER);
label3.setText("性别:");
Text text3 = new Text(parent, SWT.BORDER);
text3.setText(gender);
Label label4 = new Label(parent, SWT.BORDER);
label4.setText("年龄:");
Text text4 = new Text(parent, SWT.BORDER);
String strage = "" + age;
text4.setText(strage);
Label label5 = new Label(parent, SWT.BORDER);
label5.setText("籍贯:");
Text text5 = new Text(parent, SWT.BORDER);
text5.setText(nativePlace);
Label label6 = new Label(parent, SWT.BORDER);
label6.setText("专业:");
Text text6 = new Text(parent, SWT.BORDER);
text6.setText(profession);
*/
Label label = new Label(container, SWT.NONE);
label.setBounds(10, 10, 40, 12);
label.setText("学号:");
Label label_1 = new Label(container, SWT.NONE);
label_1.setBounds(10, 49, 40, 12);
label_1.setText("姓名:");
Label label_2 = new Label(container, SWT.NONE);
label_2.setBounds(10, 88, 40, 19);
label_2.setText("性别:");
Label label_3 = new Label(container, SWT.NONE);
label_3.setBounds(10, 136, 40, 12);
label_3.setText("年龄:");
Label label_4 = new Label(container, SWT.NONE);
label_4.setBounds(10, 184, 40, 12);
label_4.setText("籍贯:");
Label label_5 = new Label(container, SWT.NONE);
label_5.setBounds(10, 227, 40, 12);
label_5.setText("专业:");
text1 = new Text(container, SWT.BORDER);
text1.setBounds(55, 4, 150, 18);
text1.setText(strNo);
text2 = new Text(container, SWT.BORDER);
text2.setBounds(55, 43, 150, 18);
text2.setText(name);
text3 = new Text(container, SWT.BORDER);
text3.setBounds(55, 85, 150, 18);
text3.setText(gender);
text4 = new Text(container, SWT.BORDER);
text4.setBounds(55, 130, 150, 18);
text4.setText(""+age);
text5 = new Text(container, SWT.BORDER);
text5.setBounds(55, 178, 150, 18);
text5.setText(nativePlace);
text6 = new Text(container, SWT.BORDER);
text6.setBounds(55, 221, 150, 18);
text6.setText(profession);
}
@Override
public void setFocus() {
// TODO Auto-generated method stub
}
}
tianyong2011
- 粉丝: 32
- 资源: 20
最新资源
- 数据库设计管理课程设计系统设计报告(powerdesign+sql+DreamweaverCS)图书借阅管理系统设计与开发2
- 数据库设计管理课程设计系统设计报告(powerdesign+sql+DreamweaverCS)图书借阅管理系统设计与开发
- 使用大预言模型LLM构建虚拟人物画像
- 数据库设计管理课程设计系统设计报告(powerdesign+sql+DreamweaverCS)图书借阅管理系统
- 数据库设计管理课程设计系统设计报告(powerdesign+sql+DreamweaverCS)图书发行信息管理系统设计与开发
- 数据安全 数据安全基础 DSG
- Java Web 学习教程(从基础到进阶,带您逐步构建 Web 应用)
- 数据库设计管理课程设计系统设计报告(powerdesign+sql+DreamweaverCS)体育项目比赛管理系统设计与开发
- 数据库设计管理课程设计系统设计报告(powerdesign+sql+DreamweaverCS)人事管理信息系统设计与开发4
- 数据安全 数据安全治理 DSG
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈