From a61bd1a99abe9333e464b8bae7845960c003c0e8 Mon Sep 17 00:00:00 2001 From: "jinxuesong@163.com" Date: Sun, 9 May 2021 10:31:17 +0800 Subject: [PATCH] add --- .../education/action/AddCollegeAction.java | 14 +- .../education/action/AddSpecialtyAction.java | 13 +- .../education/action/AddUniversityAction.java | 13 +- .../hit/education/dialog/CollegeDialog.java | 42 +- .../edu/hit/education/dialog/LoginDialog.java | 14 +- .../hit/education/dialog/SpecialtyDialog.java | 31 +- .../hit/education/mapper/CollegeMapper.xml | 574 +++++++++--------- .../hit/education/mapper/SpecialtyMapper.xml | 573 ++++++++--------- .../hit/education/mapper/UniversityMapper.xml | 543 +++++++++-------- .../education/model/DepartmentRootNode.java | 44 +- .../education/view/DepartmentExploreView.java | 49 +- 11 files changed, 996 insertions(+), 914 deletions(-) diff --git a/src/cn/edu/hit/education/action/AddCollegeAction.java b/src/cn/edu/hit/education/action/AddCollegeAction.java index 20f4dcf..b44db96 100644 --- a/src/cn/edu/hit/education/action/AddCollegeAction.java +++ b/src/cn/edu/hit/education/action/AddCollegeAction.java @@ -8,20 +8,24 @@ import org.eclipse.ui.plugin.AbstractUIPlugin; import cn.edu.hit.education.dialog.CollegeDialog; import cn.edu.hit.education.pojo.College; +import cn.edu.hit.education.pojo.University; import cn.edu.hit.education.service.ICollegeService; +import cn.edu.hit.education.view.DepartmentExploreView; import educationschedule.Activator; import educationschedule.Application; public class AddCollegeAction extends Action { ICollegeService collegeService = (ICollegeService)Application.applicationContext.getBean("collegeServiceImpl"); private int universityId; + private DepartmentExploreView viewPart; /** * @wbp.parser.entryPoint */ - public AddCollegeAction(int universityId){ + public AddCollegeAction(DepartmentExploreView viewPart,int universityId){ this.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(Activator.PLUGIN_ID, "icons/toolbar/course_code_16px.png")); this.setToolTipText("增加学院"); this.setText("增加学院"); + this.viewPart = viewPart; this.universityId = universityId; } @@ -29,10 +33,14 @@ public class AddCollegeAction extends Action { public void run() { Shell parentShell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); CollegeDialog collegeDialog = new CollegeDialog(parentShell); + College college = new College(); + collegeDialog.setCollege(college); if(IDialogConstants.OK_ID == collegeDialog.open()){ - College college = collegeDialog.getCollege(); college.setUniversityId(universityId); - collegeService.insert(college); + int count = collegeService.insert(college); + if(count > 0){ + viewPart.refreshData(college); + } } super.run(); } diff --git a/src/cn/edu/hit/education/action/AddSpecialtyAction.java b/src/cn/edu/hit/education/action/AddSpecialtyAction.java index e05b573..89c8a9a 100644 --- a/src/cn/edu/hit/education/action/AddSpecialtyAction.java +++ b/src/cn/edu/hit/education/action/AddSpecialtyAction.java @@ -9,19 +9,22 @@ import org.eclipse.ui.plugin.AbstractUIPlugin; import cn.edu.hit.education.dialog.SpecialtyDialog; import cn.edu.hit.education.pojo.Specialty; import cn.edu.hit.education.service.ISpecialtyService; +import cn.edu.hit.education.view.DepartmentExploreView; import educationschedule.Activator; import educationschedule.Application; public class AddSpecialtyAction extends Action { ISpecialtyService specialtyService = (ISpecialtyService)Application.applicationContext.getBean("specialtyServiceImpl"); private int collegeId; + private DepartmentExploreView viewPart; /** * @wbp.parser.entryPoint */ - public AddSpecialtyAction(int collegeId){ + public AddSpecialtyAction(DepartmentExploreView viewPart,int collegeId){ this.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(Activator.PLUGIN_ID, "icons/toolbar/course_code_16px.png")); this.setToolTipText("增加专业"); this.setText("增加专业"); + this.viewPart = viewPart; this.collegeId = collegeId; } @@ -29,10 +32,14 @@ public class AddSpecialtyAction extends Action { public void run() { Shell parentShell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); SpecialtyDialog specialtyDialog = new SpecialtyDialog(parentShell); + Specialty specialty = new Specialty(); + specialtyDialog.setSpecialty(specialty); if(IDialogConstants.OK_ID == specialtyDialog.open()){ - Specialty specialty = specialtyDialog.getSpecialty(); specialty.setCollegeId(collegeId); - specialtyService.insert(specialty); + int count = specialtyService.insert(specialty); + if(count > 0){ + viewPart.refreshData(specialty); + } } super.run(); } diff --git a/src/cn/edu/hit/education/action/AddUniversityAction.java b/src/cn/edu/hit/education/action/AddUniversityAction.java index 0e6d62d..2b59842 100644 --- a/src/cn/edu/hit/education/action/AddUniversityAction.java +++ b/src/cn/edu/hit/education/action/AddUniversityAction.java @@ -9,25 +9,32 @@ import org.eclipse.ui.plugin.AbstractUIPlugin; import cn.edu.hit.education.dialog.UniversityDialog; import cn.edu.hit.education.pojo.University; import cn.edu.hit.education.service.IUniversityService; +import cn.edu.hit.education.view.DepartmentExploreView; import educationschedule.Activator; import educationschedule.Application; public class AddUniversityAction extends Action { + private DepartmentExploreView viewPart; IUniversityService universityService = (IUniversityService)Application.applicationContext.getBean("universityServiceImpl"); - public AddUniversityAction(){ + public AddUniversityAction(DepartmentExploreView viewPart){ this.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(Activator.PLUGIN_ID, "icons/toolbar/course_code_16px.png")); this.setToolTipText("增加学校"); this.setText("增加学校"); + this.viewPart = viewPart; } @Override public void run() { Shell parentShell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); UniversityDialog universityDialog = new UniversityDialog(parentShell); + University university = new University(); + universityDialog.setUniversity(university); if(IDialogConstants.OK_ID == universityDialog.open()){ - //universityService.insert(universityDialog.getUniversity()); - University u = universityDialog.getUniversity(); + int count = universityService.insert(university); + if(count > 0){ + viewPart.refreshData(university); + } } super.run(); } diff --git a/src/cn/edu/hit/education/dialog/CollegeDialog.java b/src/cn/edu/hit/education/dialog/CollegeDialog.java index 81e1808..6720054 100644 --- a/src/cn/edu/hit/education/dialog/CollegeDialog.java +++ b/src/cn/edu/hit/education/dialog/CollegeDialog.java @@ -16,13 +16,16 @@ import org.eclipse.swt.widgets.Text; import cn.edu.hit.education.pojo.College; import cn.edu.hit.education.pojo.University; import educationschedule.Activator; +import org.eclipse.core.databinding.DataBindingContext; +import org.eclipse.core.databinding.observable.value.IObservableValue; +import org.eclipse.jface.databinding.swt.WidgetProperties; +import org.eclipse.core.databinding.beans.PojoProperties; public class CollegeDialog extends TitleAreaDialog { + private DataBindingContext m_bindingContext; IPreferenceStore store = Activator.getDefault().getPreferenceStore(); - private DecimalFormat df2 = new DecimalFormat("0.00"); - private Text text; private Text textName; - private Text textAddress; + private Text textCode; private Text textNode; private College college; @@ -45,19 +48,13 @@ public class CollegeDialog extends TitleAreaDialog { textName = new Text(composite_1, SWT.BORDER); textName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); - if(college != null && college.getName() != null){ - textName.setText(college.getName()); - } Label label_1 = new Label(composite_1, SWT.NONE); label_1.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); label_1.setText("学院编码"); - textAddress = new Text(composite_1, SWT.BORDER); - textAddress.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); - if(college != null && college.getCode() != null){ - textAddress.setText(college.getCode()); - } + textCode = new Text(composite_1, SWT.BORDER); + textCode.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); Label label_2 = new Label(composite_1, SWT.NONE); label_2.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); @@ -65,9 +62,7 @@ public class CollegeDialog extends TitleAreaDialog { textNode = new Text(composite_1, SWT.BORDER); textNode.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); - if(college != null && college.getNote() != null){ - textNode.setText(college.getNote()); - } + m_bindingContext = initDataBindings(); return composite; } @@ -84,6 +79,21 @@ public class CollegeDialog extends TitleAreaDialog { public void setCollege(College college) { this.college = college; } - - + protected DataBindingContext initDataBindings() { + DataBindingContext bindingContext = new DataBindingContext(); + // + IObservableValue observeTextTextNameObserveWidget = WidgetProperties.text(SWT.Modify).observe(textName); + IObservableValue nameCollegeObserveValue = PojoProperties.value("name").observe(college); + bindingContext.bindValue(observeTextTextNameObserveWidget, nameCollegeObserveValue, null, null); + // + IObservableValue observeTextTextCodeObserveWidget = WidgetProperties.text(SWT.Modify).observe(textCode); + IObservableValue codeCollegeObserveValue = PojoProperties.value("code").observe(college); + bindingContext.bindValue(observeTextTextCodeObserveWidget, codeCollegeObserveValue, null, null); + // + IObservableValue observeTextTextNodeObserveWidget = WidgetProperties.text(SWT.Modify).observe(textNode); + IObservableValue noteCollegeObserveValue = PojoProperties.value("note").observe(college); + bindingContext.bindValue(observeTextTextNodeObserveWidget, noteCollegeObserveValue, null, null); + // + return bindingContext; + } } diff --git a/src/cn/edu/hit/education/dialog/LoginDialog.java b/src/cn/edu/hit/education/dialog/LoginDialog.java index ad65e11..638dfab 100644 --- a/src/cn/edu/hit/education/dialog/LoginDialog.java +++ b/src/cn/edu/hit/education/dialog/LoginDialog.java @@ -8,15 +8,10 @@ */ package cn.edu.hit.education.dialog; -import org.apache.shiro.SecurityUtils; import org.apache.shiro.authc.AuthenticationException; import org.apache.shiro.authc.IncorrectCredentialsException; import org.apache.shiro.authc.LockedAccountException; import org.apache.shiro.authc.UnknownAccountException; -import org.apache.shiro.authc.UsernamePasswordToken; -import org.apache.shiro.mgt.DefaultSecurityManager; -import org.apache.shiro.subject.Subject; -import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.IMessageProvider; import org.eclipse.jface.dialogs.TitleAreaDialog; import org.eclipse.swt.SWT; @@ -33,11 +28,8 @@ import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.MessageBox; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; import cn.edu.hit.education.service.IUserService; -import cn.edu.hit.education.shiro.UserRealm; import educationschedule.Application; /** @@ -107,6 +99,7 @@ public class LoginDialog extends TitleAreaDialog { fd_textUsername.left = new FormAttachment(label_name, 6); fd_textUsername.right = new FormAttachment(100, -38); textUsername.setLayoutData(fd_textUsername); + textUsername.setText("admin"); textPassword = new Text(composite, SWT.BORDER | SWT.PASSWORD); fd_textUsername.bottom = new FormAttachment(textPassword, -24); @@ -116,6 +109,7 @@ public class LoginDialog extends TitleAreaDialog { checkValid(); } }); + textPassword.setText("456789"); final FormData fd_textPassword = new FormData(); fd_textPassword.left = new FormAttachment(textUsername, 0, SWT.LEFT); fd_textPassword.right = new FormAttachment(100, -38); @@ -174,7 +168,7 @@ public class LoginDialog extends TitleAreaDialog { protected void okPressed() { // TODO Auto-generated method stub System.out.println(textUsername.getText()); - /*try { + try { userService.login(textUsername.getText(), textPassword.getText()); super.okPressed(); } catch (AuthenticationException e) { @@ -207,6 +201,6 @@ public class LoginDialog extends TitleAreaDialog { messageBox.setMessage("认证失败!"); messageBox.open(); } - }*/ + } } } diff --git a/src/cn/edu/hit/education/dialog/SpecialtyDialog.java b/src/cn/edu/hit/education/dialog/SpecialtyDialog.java index 648da03..768a6db 100644 --- a/src/cn/edu/hit/education/dialog/SpecialtyDialog.java +++ b/src/cn/edu/hit/education/dialog/SpecialtyDialog.java @@ -16,13 +16,18 @@ import org.eclipse.swt.widgets.Text; import cn.edu.hit.education.pojo.Specialty; import cn.edu.hit.education.pojo.University; import educationschedule.Activator; +import org.eclipse.core.databinding.DataBindingContext; +import org.eclipse.core.databinding.observable.value.IObservableValue; +import org.eclipse.jface.databinding.swt.WidgetProperties; +import org.eclipse.core.databinding.beans.PojoProperties; public class SpecialtyDialog extends TitleAreaDialog { + private DataBindingContext m_bindingContext; IPreferenceStore store = Activator.getDefault().getPreferenceStore(); private DecimalFormat df2 = new DecimalFormat("0.00"); private Text text; private Text textName; - private Text textAddress; + private Text textCode; private Text textNode; private Specialty specialty; @@ -53,10 +58,10 @@ public class SpecialtyDialog extends TitleAreaDialog { label_1.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); label_1.setText("专业编码"); - textAddress = new Text(composite_1, SWT.BORDER); - textAddress.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); + textCode = new Text(composite_1, SWT.BORDER); + textCode.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); if(specialty != null && specialty.getCode() != null){ - textAddress.setText(specialty.getCode()); + textCode.setText(specialty.getCode()); } Label label_2 = new Label(composite_1, SWT.NONE); @@ -68,6 +73,7 @@ public class SpecialtyDialog extends TitleAreaDialog { if(specialty != null && specialty.getNote() != null){ textNode.setText(specialty.getNote()); } + m_bindingContext = initDataBindings(); return composite; } @@ -84,4 +90,21 @@ public class SpecialtyDialog extends TitleAreaDialog { public void setSpecialty(Specialty specialty) { this.specialty = specialty; } + protected DataBindingContext initDataBindings() { + DataBindingContext bindingContext = new DataBindingContext(); + // + IObservableValue observeTextTextNameObserveWidget = WidgetProperties.text(SWT.Modify).observe(textName); + IObservableValue nameSpecialtyObserveValue = PojoProperties.value("name").observe(specialty); + bindingContext.bindValue(observeTextTextNameObserveWidget, nameSpecialtyObserveValue, null, null); + // + IObservableValue observeTextTextCodeObserveWidget = WidgetProperties.text(SWT.Modify).observe(textCode); + IObservableValue codeSpecialtyObserveValue = PojoProperties.value("code").observe(specialty); + bindingContext.bindValue(observeTextTextCodeObserveWidget, codeSpecialtyObserveValue, null, null); + // + IObservableValue observeTextTextNodeObserveWidget = WidgetProperties.text(SWT.Modify).observe(textNode); + IObservableValue noteSpecialtyObserveValue = PojoProperties.value("note").observe(specialty); + bindingContext.bindValue(observeTextTextNodeObserveWidget, noteSpecialtyObserveValue, null, null); + // + return bindingContext; + } } diff --git a/src/cn/edu/hit/education/mapper/CollegeMapper.xml b/src/cn/edu/hit/education/mapper/CollegeMapper.xml index 2744fee..6424f97 100644 --- a/src/cn/edu/hit/education/mapper/CollegeMapper.xml +++ b/src/cn/edu/hit/education/mapper/CollegeMapper.xml @@ -1,286 +1,290 @@ - - - - - - - - - - - - - - - - - - - - - and ${criterion.condition} - - - and ${criterion.condition} #{criterion.value} - - - and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} - - - and ${criterion.condition} - - #{listItem} - - - - - - - - - - - - - - - - - - - and ${criterion.condition} - - - and ${criterion.condition} #{criterion.value} - - - and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} - - - and ${criterion.condition} - - #{listItem} - - - - - - - - - - - - id, name, university_id, code, note - - - - - - delete from college - where id = #{id,jdbcType=INTEGER} - - - - delete from college - - - - - - - insert into college (id, name, university_id, - code, note) - values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{universityId,jdbcType=INTEGER}, - #{code,jdbcType=VARCHAR}, #{note,jdbcType=VARCHAR}) - - - - insert into college - - - id, - - - name, - - - university_id, - - - code, - - - note, - - - - - #{id,jdbcType=INTEGER}, - - - #{name,jdbcType=VARCHAR}, - - - #{universityId,jdbcType=INTEGER}, - - - #{code,jdbcType=VARCHAR}, - - - #{note,jdbcType=VARCHAR}, - - - - - - - update college - - - id = #{record.id,jdbcType=INTEGER}, - - - name = #{record.name,jdbcType=VARCHAR}, - - - university_id = #{record.universityId,jdbcType=INTEGER}, - - - code = #{record.code,jdbcType=VARCHAR}, - - - note = #{record.note,jdbcType=VARCHAR}, - - - - - - - - - update college - set id = #{record.id,jdbcType=INTEGER}, - name = #{record.name,jdbcType=VARCHAR}, - university_id = #{record.universityId,jdbcType=INTEGER}, - code = #{record.code,jdbcType=VARCHAR}, - note = #{record.note,jdbcType=VARCHAR} - - - - - - - update college - - - name = #{name,jdbcType=VARCHAR}, - - - university_id = #{universityId,jdbcType=INTEGER}, - - - code = #{code,jdbcType=VARCHAR}, - - - note = #{note,jdbcType=VARCHAR}, - - - where id = #{id,jdbcType=INTEGER} - - - - update college - set name = #{name,jdbcType=VARCHAR}, - university_id = #{universityId,jdbcType=INTEGER}, - code = #{code,jdbcType=VARCHAR}, - note = #{note,jdbcType=VARCHAR} - where id = #{id,jdbcType=INTEGER} - + + + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + id, name, university_id, code, note + + + + + + delete from college + where id = #{id,jdbcType=INTEGER} + + + + delete from college + + + + + + + insert into college (id, name, university_id, + code, note) + values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{universityId,jdbcType=INTEGER}, + #{code,jdbcType=VARCHAR}, #{note,jdbcType=VARCHAR}) + + + select LAST_INSERT_ID() as id + + + + + insert into college + + + id, + + + name, + + + university_id, + + + code, + + + note, + + + + + #{id,jdbcType=INTEGER}, + + + #{name,jdbcType=VARCHAR}, + + + #{universityId,jdbcType=INTEGER}, + + + #{code,jdbcType=VARCHAR}, + + + #{note,jdbcType=VARCHAR}, + + + + + + + update college + + + id = #{record.id,jdbcType=INTEGER}, + + + name = #{record.name,jdbcType=VARCHAR}, + + + university_id = #{record.universityId,jdbcType=INTEGER}, + + + code = #{record.code,jdbcType=VARCHAR}, + + + note = #{record.note,jdbcType=VARCHAR}, + + + + + + + + + update college + set id = #{record.id,jdbcType=INTEGER}, + name = #{record.name,jdbcType=VARCHAR}, + university_id = #{record.universityId,jdbcType=INTEGER}, + code = #{record.code,jdbcType=VARCHAR}, + note = #{record.note,jdbcType=VARCHAR} + + + + + + + update college + + + name = #{name,jdbcType=VARCHAR}, + + + university_id = #{universityId,jdbcType=INTEGER}, + + + code = #{code,jdbcType=VARCHAR}, + + + note = #{note,jdbcType=VARCHAR}, + + + where id = #{id,jdbcType=INTEGER} + + + + update college + set name = #{name,jdbcType=VARCHAR}, + university_id = #{universityId,jdbcType=INTEGER}, + code = #{code,jdbcType=VARCHAR}, + note = #{note,jdbcType=VARCHAR} + where id = #{id,jdbcType=INTEGER} + \ No newline at end of file diff --git a/src/cn/edu/hit/education/mapper/SpecialtyMapper.xml b/src/cn/edu/hit/education/mapper/SpecialtyMapper.xml index 4527afb..1e175a3 100644 --- a/src/cn/edu/hit/education/mapper/SpecialtyMapper.xml +++ b/src/cn/edu/hit/education/mapper/SpecialtyMapper.xml @@ -1,286 +1,289 @@ - - - - - - - - - - - - - - - - - - - - - and ${criterion.condition} - - - and ${criterion.condition} #{criterion.value} - - - and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} - - - and ${criterion.condition} - - #{listItem} - - - - - - - - - - - - - - - - - - - and ${criterion.condition} - - - and ${criterion.condition} #{criterion.value} - - - and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} - - - and ${criterion.condition} - - #{listItem} - - - - - - - - - - - - id, name, college_id, code, note - - - - - - delete from specialty - where id = #{id,jdbcType=INTEGER} - - - - delete from specialty - - - - - - - insert into specialty (id, name, college_id, - code, note) - values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{collegeId,jdbcType=INTEGER}, - #{code,jdbcType=VARCHAR}, #{note,jdbcType=VARCHAR}) - - - - insert into specialty - - - id, - - - name, - - - college_id, - - - code, - - - note, - - - - - #{id,jdbcType=INTEGER}, - - - #{name,jdbcType=VARCHAR}, - - - #{collegeId,jdbcType=INTEGER}, - - - #{code,jdbcType=VARCHAR}, - - - #{note,jdbcType=VARCHAR}, - - - - - - - update specialty - - - id = #{record.id,jdbcType=INTEGER}, - - - name = #{record.name,jdbcType=VARCHAR}, - - - college_id = #{record.collegeId,jdbcType=INTEGER}, - - - code = #{record.code,jdbcType=VARCHAR}, - - - note = #{record.note,jdbcType=VARCHAR}, - - - - - - - - - update specialty - set id = #{record.id,jdbcType=INTEGER}, - name = #{record.name,jdbcType=VARCHAR}, - college_id = #{record.collegeId,jdbcType=INTEGER}, - code = #{record.code,jdbcType=VARCHAR}, - note = #{record.note,jdbcType=VARCHAR} - - - - - - - update specialty - - - name = #{name,jdbcType=VARCHAR}, - - - college_id = #{collegeId,jdbcType=INTEGER}, - - - code = #{code,jdbcType=VARCHAR}, - - - note = #{note,jdbcType=VARCHAR}, - - - where id = #{id,jdbcType=INTEGER} - - - - update specialty - set name = #{name,jdbcType=VARCHAR}, - college_id = #{collegeId,jdbcType=INTEGER}, - code = #{code,jdbcType=VARCHAR}, - note = #{note,jdbcType=VARCHAR} - where id = #{id,jdbcType=INTEGER} - + + + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + id, name, college_id, code, note + + + + + + delete from specialty + where id = #{id,jdbcType=INTEGER} + + + + delete from specialty + + + + + + + insert into specialty (id, name, college_id, + code, note) + values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{collegeId,jdbcType=INTEGER}, + #{code,jdbcType=VARCHAR}, #{note,jdbcType=VARCHAR}) + + select LAST_INSERT_ID() as id + + + + + insert into specialty + + + id, + + + name, + + + college_id, + + + code, + + + note, + + + + + #{id,jdbcType=INTEGER}, + + + #{name,jdbcType=VARCHAR}, + + + #{collegeId,jdbcType=INTEGER}, + + + #{code,jdbcType=VARCHAR}, + + + #{note,jdbcType=VARCHAR}, + + + + + + + update specialty + + + id = #{record.id,jdbcType=INTEGER}, + + + name = #{record.name,jdbcType=VARCHAR}, + + + college_id = #{record.collegeId,jdbcType=INTEGER}, + + + code = #{record.code,jdbcType=VARCHAR}, + + + note = #{record.note,jdbcType=VARCHAR}, + + + + + + + + + update specialty + set id = #{record.id,jdbcType=INTEGER}, + name = #{record.name,jdbcType=VARCHAR}, + college_id = #{record.collegeId,jdbcType=INTEGER}, + code = #{record.code,jdbcType=VARCHAR}, + note = #{record.note,jdbcType=VARCHAR} + + + + + + + update specialty + + + name = #{name,jdbcType=VARCHAR}, + + + college_id = #{collegeId,jdbcType=INTEGER}, + + + code = #{code,jdbcType=VARCHAR}, + + + note = #{note,jdbcType=VARCHAR}, + + + where id = #{id,jdbcType=INTEGER} + + + + update specialty + set name = #{name,jdbcType=VARCHAR}, + college_id = #{collegeId,jdbcType=INTEGER}, + code = #{code,jdbcType=VARCHAR}, + note = #{note,jdbcType=VARCHAR} + where id = #{id,jdbcType=INTEGER} + \ No newline at end of file diff --git a/src/cn/edu/hit/education/mapper/UniversityMapper.xml b/src/cn/edu/hit/education/mapper/UniversityMapper.xml index f549e9a..5a476c9 100644 --- a/src/cn/edu/hit/education/mapper/UniversityMapper.xml +++ b/src/cn/edu/hit/education/mapper/UniversityMapper.xml @@ -1,271 +1,274 @@ - - - - - - - - - - - - - - - - - - - - and ${criterion.condition} - - - and ${criterion.condition} #{criterion.value} - - - and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} - - - and ${criterion.condition} - - #{listItem} - - - - - - - - - - - - - - - - - - - and ${criterion.condition} - - - and ${criterion.condition} #{criterion.value} - - - and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} - - - and ${criterion.condition} - - #{listItem} - - - - - - - - - - - - id, name, address, note - - - - - - delete from university - where id = #{id,jdbcType=INTEGER} - - - - delete from university - - - - - - - insert into university (id, name, address, - note) - values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{address,jdbcType=VARCHAR}, - #{note,jdbcType=VARCHAR}) - - - - insert into university - - - id, - - - name, - - - address, - - - note, - - - - - #{id,jdbcType=INTEGER}, - - - #{name,jdbcType=VARCHAR}, - - - #{address,jdbcType=VARCHAR}, - - - #{note,jdbcType=VARCHAR}, - - - - - - - update university - - - id = #{record.id,jdbcType=INTEGER}, - - - name = #{record.name,jdbcType=VARCHAR}, - - - address = #{record.address,jdbcType=VARCHAR}, - - - note = #{record.note,jdbcType=VARCHAR}, - - - - - - - - - update university - set id = #{record.id,jdbcType=INTEGER}, - name = #{record.name,jdbcType=VARCHAR}, - address = #{record.address,jdbcType=VARCHAR}, - note = #{record.note,jdbcType=VARCHAR} - - - - - - - update university - - - name = #{name,jdbcType=VARCHAR}, - - - address = #{address,jdbcType=VARCHAR}, - - - note = #{note,jdbcType=VARCHAR}, - - - where id = #{id,jdbcType=INTEGER} - - - - update university - set name = #{name,jdbcType=VARCHAR}, - address = #{address,jdbcType=VARCHAR}, - note = #{note,jdbcType=VARCHAR} - where id = #{id,jdbcType=INTEGER} - + + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + + + + + + + + and ${criterion.condition} + + + and ${criterion.condition} #{criterion.value} + + + and ${criterion.condition} #{criterion.value} and #{criterion.secondValue} + + + and ${criterion.condition} + + #{listItem} + + + + + + + + + + + + id, name, address, note + + + + + + delete from university + where id = #{id,jdbcType=INTEGER} + + + + delete from university + + + + + + + insert into university (id, name, address, + note) + values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{address,jdbcType=VARCHAR}, + #{note,jdbcType=VARCHAR}) + + select LAST_INSERT_ID() as id + + + + + insert into university + + + id, + + + name, + + + address, + + + note, + + + + + #{id,jdbcType=INTEGER}, + + + #{name,jdbcType=VARCHAR}, + + + #{address,jdbcType=VARCHAR}, + + + #{note,jdbcType=VARCHAR}, + + + + + + + update university + + + id = #{record.id,jdbcType=INTEGER}, + + + name = #{record.name,jdbcType=VARCHAR}, + + + address = #{record.address,jdbcType=VARCHAR}, + + + note = #{record.note,jdbcType=VARCHAR}, + + + + + + + + + update university + set id = #{record.id,jdbcType=INTEGER}, + name = #{record.name,jdbcType=VARCHAR}, + address = #{record.address,jdbcType=VARCHAR}, + note = #{record.note,jdbcType=VARCHAR} + + + + + + + update university + + + name = #{name,jdbcType=VARCHAR}, + + + address = #{address,jdbcType=VARCHAR}, + + + note = #{note,jdbcType=VARCHAR}, + + + where id = #{id,jdbcType=INTEGER} + + + + update university + set name = #{name,jdbcType=VARCHAR}, + address = #{address,jdbcType=VARCHAR}, + note = #{note,jdbcType=VARCHAR} + where id = #{id,jdbcType=INTEGER} + \ No newline at end of file diff --git a/src/cn/edu/hit/education/model/DepartmentRootNode.java b/src/cn/edu/hit/education/model/DepartmentRootNode.java index ed64d3f..61007d8 100644 --- a/src/cn/edu/hit/education/model/DepartmentRootNode.java +++ b/src/cn/edu/hit/education/model/DepartmentRootNode.java @@ -21,39 +21,43 @@ public class DepartmentRootNode extends Node { } public static synchronized DepartmentRootNode getRootNode() { - if (root == null) { + //if (root == null) + { root = new DepartmentRootNode(); root.setParent(null); - root.initRootNode(1); + root.initRootNode(); } return root; } - private void initRootNode(int universityId) { - University theUniversity = universityService.queryUniversityByPrimaryKey(universityId); + private void initRootNode() { + OrganizationNode organizationNode = new OrganizationNode(0,"组织结构"); root.addChild(organizationNode); - if(theUniversity != null){ - UniversityNode universityNode = new UniversityNode(theUniversity.getId(),theUniversity.getName()); - organizationNode.addChild(universityNode); - - List colleges = collegeService.queryCollegesByUniversityId(theUniversity.getId()); - if(colleges != null && colleges.size() > 0){ - for (College college : colleges) { - CollegeNode collegeNode = new CollegeNode(college.getId(),college.getName()); - universityNode.addChild(collegeNode); - - List specialties = specialtyService.querySpecialtiesByCollegeId(college.getId()); - if(specialties != null && specialties.size() > 0){ - for (Specialty specialty : specialties) { - SpecialtyNode specialtyNode = new SpecialtyNode(specialty.getId(),specialty.getName()); - collegeNode.addChild(specialtyNode); + List universities = universityService.queryAllUniversity(); + + if(universities != null && universities.size() > 0){ + for (University university : universities) { + UniversityNode universityNode = new UniversityNode(university.getId(),university.getName()); + organizationNode.addChild(universityNode); + + List colleges = collegeService.queryCollegesByUniversityId(university.getId()); + if(colleges != null && colleges.size() > 0){ + for (College college : colleges) { + CollegeNode collegeNode = new CollegeNode(college.getId(),college.getName()); + universityNode.addChild(collegeNode); + + List specialties = specialtyService.querySpecialtiesByCollegeId(college.getId()); + if(specialties != null && specialties.size() > 0){ + for (Specialty specialty : specialties) { + SpecialtyNode specialtyNode = new SpecialtyNode(specialty.getId(),specialty.getName()); + collegeNode.addChild(specialtyNode); + } } } } } - } } } diff --git a/src/cn/edu/hit/education/view/DepartmentExploreView.java b/src/cn/edu/hit/education/view/DepartmentExploreView.java index 5b980e5..ea68be4 100644 --- a/src/cn/edu/hit/education/view/DepartmentExploreView.java +++ b/src/cn/edu/hit/education/view/DepartmentExploreView.java @@ -6,16 +6,9 @@ import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Menu; -import org.eclipse.swt.widgets.MenuItem; import org.eclipse.swt.widgets.Tree; -import org.eclipse.swt.widgets.TreeItem; import org.eclipse.ui.part.ViewPart; import org.springframework.stereotype.Component; @@ -25,12 +18,14 @@ import cn.edu.hit.education.action.AddUniversityAction; import cn.edu.hit.education.contentprovider.DepartmentContentProvider; import cn.edu.hit.education.labelprovider.DepartmentLabelProvider; import cn.edu.hit.education.model.CollegeNode; -import cn.edu.hit.education.model.CourseNode; import cn.edu.hit.education.model.DepartmentRootNode; import cn.edu.hit.education.model.Node; import cn.edu.hit.education.model.OrganizationNode; import cn.edu.hit.education.model.SpecialtyNode; import cn.edu.hit.education.model.UniversityNode; +import cn.edu.hit.education.pojo.College; +import cn.edu.hit.education.pojo.Specialty; +import cn.edu.hit.education.pojo.University; @Component public class DepartmentExploreView extends ViewPart { @@ -71,14 +66,14 @@ public class DepartmentExploreView extends ViewPart { if (treeViewer.getSelection() instanceof IStructuredSelection) { IStructuredSelection selection = (IStructuredSelection) treeViewer.getSelection(); - Node node = (Node)selection.getFirstElement(); + currentNode = (Node)selection.getFirstElement(); - if(node instanceof OrganizationNode){ - menuMgr.add(new AddUniversityAction()); - }else if(node instanceof UniversityNode){ - menuMgr.add(new AddCollegeAction(node.getId())); - }else if(node instanceof CollegeNode){ - menuMgr.add(new AddSpecialtyAction(node.getId())); + if(currentNode instanceof OrganizationNode){ + menuMgr.add(new AddUniversityAction(DepartmentExploreView.this)); + }else if(currentNode instanceof UniversityNode){ + menuMgr.add(new AddCollegeAction(DepartmentExploreView.this,currentNode.getId())); + }else if(currentNode instanceof CollegeNode){ + menuMgr.add(new AddSpecialtyAction(DepartmentExploreView.this,currentNode.getId())); }else{ } @@ -87,6 +82,30 @@ public class DepartmentExploreView extends ViewPart { }); menuMgr.setRemoveAllWhenShown(true); treeViewer.getControl().setMenu(menu); + + } + + public void refreshData(Object obj){ + if(obj instanceof University){ + University university = (University)obj; + UniversityNode universityNode = new UniversityNode(university.getId(),university.getName()); + treeViewer.add(currentNode, universityNode); + }else if(obj instanceof College){ + College college = (College)obj; + CollegeNode collegeNode = new CollegeNode(college.getId(),college.getName()); + treeViewer.add(currentNode, collegeNode); + }else if(obj instanceof Specialty){ + Specialty specialty = (Specialty)obj; + SpecialtyNode specialtyNode = new SpecialtyNode(specialty.getId(),specialty.getName()); + treeViewer.add(currentNode, specialtyNode); + }else{ + + } + + Object nodes = treeViewer.getInput(); + //treeViewer.refresh(); + treeViewer.setExpandedState(currentNode, true); + } /** -- Gitee