diff --git a/.classpath b/.classpath
index 9e70d8dc152a4d4c0aaed0f2ff5c9b69394c1d38..2f69697311bae2e43cbd0eaf9949056ccb0822e3 100644
--- a/.classpath
+++ b/.classpath
@@ -1,53 +1,53 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/cn/edu/hit/education/dialog/SeparateCourseDialog.java b/src/cn/edu/hit/education/dialog/SeparateCourseDialog.java
index d9a8e5bf920a2aa119e96c7865ff4e9b6b20f92b..6dae7bbe78de64c9c86ec62ab2a0655f5d48f426 100644
--- a/src/cn/edu/hit/education/dialog/SeparateCourseDialog.java
+++ b/src/cn/edu/hit/education/dialog/SeparateCourseDialog.java
@@ -1,5 +1,6 @@
package cn.edu.hit.education.dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.jface.dialogs.TitleAreaDialog;
import org.eclipse.swt.SWT;
@@ -11,29 +12,49 @@ import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+import org.springframework.stereotype.Component;
+
+import cn.edu.hit.education.pojo.Schedule;
+import cn.edu.hit.education.service.ICourseService;
+import cn.edu.hit.education.service.IScheduleService;
+import cn.edu.hit.education.service.ISemesterService;
+import cn.edu.hit.education.service.ISpecialtyService;
+import cn.edu.hit.education.service.ScheduleServiceImpl;
+import cn.edu.hit.education.view.CourseScheduleView;
+import educationschedule.Application;
/**
*@Title: separateCourse
*@Description:分散授课设置
*@author:李朝辉
-*@data:2021年4月29日午夜12:00
+*@data:2021年5月5日下午2:00
*
*/
public class SeparateCourseDialog extends TitleAreaDialog {
+
+ CourseScheduleView courseScheduleview = Application.applicationContext.getBean(CourseScheduleView.class);
private Text text;
private Text text_1;
private Text text_2;
private Text text_3;
+ private int courseId;
+ private IScheduleService scheduleService= Application.applicationContext.getBean(IScheduleService.class);
+ private int semesterId = courseScheduleview.getSemester().getId();
+ private int specialityId = courseScheduleview.getSpecialty().getId();
-
- public SeparateCourseDialog(Shell parentShell) {
+ public SeparateCourseDialog(Shell parentShell,int courseId) {
super(parentShell);
+ this.courseId = courseId;
// TODO Auto-generated constructor stub
}
protected Control createDialogArea(Composite parent) {
Composite composite = (Composite)super.createDialogArea(parent);
createContentPane(composite);
+
return composite;
}
@@ -83,8 +104,43 @@ public class SeparateCourseDialog extends TitleAreaDialog {
super.configureShell(newShell);
newShell.setText("分散课程设置");
}
+
+ protected void createButtonsForButtonBar(Composite parent) {
+ createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
+ createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
+ }
protected Point getInitialSize() {
// TODO 自动生成的方法存根
return new Point(300,300);
}
+ protected void okPressed() {
+ // implement your own function here
+ Schedule schedule = new Schedule();
+ schedule.setCourseId(courseId);
+ schedule.setSpecialtyId(semesterId);
+ schedule.setSemesterId(specialityId);
+ schedule.setPeriod(getPeriod());
+ schedule.setCredits(getCredit());
+ schedule.setTheoretical(getTheoretical());
+ schedule.setExperiment(getExperiment());
+ scheduleService.insert(schedule);
+ System.out.println("注入成功!");
+
+ super.okPressed();
+ }
+
+
+ public double getCredit() {
+ return Double.parseDouble(text.getText());
+ }
+ public double getPeriod() {
+ return Double.parseDouble(text_1.getText());
+ }
+ public double getTheoretical() {
+ return Double.parseDouble(text_2.getText());
+ }
+ public double getExperiment() {
+ return Double.parseDouble(text_3.getText());
+ }
+
}
diff --git a/src/cn/edu/hit/education/view/CourseExploreView.java b/src/cn/edu/hit/education/view/CourseExploreView.java
index f49ecf257f3e572b6116d047711b751c38e28ddb..ffa13c29158fa3fb6b1de16f70f6510ab5359580 100644
--- a/src/cn/edu/hit/education/view/CourseExploreView.java
+++ b/src/cn/edu/hit/education/view/CourseExploreView.java
@@ -70,6 +70,9 @@ public class CourseExploreView extends ViewPart {
private TreeViewer treeViewer;
private Semester semester;
private Specialty specialty;
+ private CourseNode courseNode ;
+
+
public CourseExploreView() {
@@ -91,10 +94,10 @@ public class CourseExploreView extends ViewPart {
@Override
public void widgetSelected(SelectionEvent e) {
TreeItem selections = (TreeItem)e.item;
- CourseNode courseNode = (CourseNode)selections.getData();
+ courseNode = (CourseNode)selections.getData();
-
- System.out.println("所选课程ID:"+courseNode.getId()+ "结果打印"+scheduleService.qurySchedule(courseNode.getId()).toString());
+
+ System.out.println("所选课程ID:"+courseNode.getId());
}
});
@@ -116,9 +119,9 @@ public class CourseExploreView extends ViewPart {
// TODO :弹出窗口实现
Shell parentShell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
- SeparateCourseDialog dlg = new SeparateCourseDialog(parentShell);
+ SeparateCourseDialog dlg = new SeparateCourseDialog(parentShell, courseNode.getId());
+
if(IDialogConstants.OK_ID == dlg.open()){
-
}
}
diff --git a/src/cn/edu/hit/education/view/CourseScheduleView.java b/src/cn/edu/hit/education/view/CourseScheduleView.java
index 54a1fec2626fbd0cf0537e4ed7f97a5a10983949..9bbd5ac8234cb81828366e922fe68d9467733309 100644
--- a/src/cn/edu/hit/education/view/CourseScheduleView.java
+++ b/src/cn/edu/hit/education/view/CourseScheduleView.java
@@ -7,6 +7,9 @@ import java.util.Set;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.util.LocalSelectionTransfer;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.swt.SWT;
@@ -28,6 +31,7 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.ui.ISelectionService;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.ViewPart;
import org.springframework.beans.factory.annotation.Autowired;
@@ -48,7 +52,7 @@ import cn.edu.hit.education.service.ISpecialtyService;
import cn.edu.hit.education.utils.StatisticsUtil;
@Component
-public class CourseScheduleView extends ViewPart {
+public class CourseScheduleView extends ViewPart implements ISelectionProvider{
public static final String ID = "cn.edu.hit.education.view.CourseScheduleView";
final Transfer[] transfer = new Transfer[] { LocalSelectionTransfer
.getTransfer() };
@@ -69,9 +73,11 @@ public class CourseScheduleView extends ViewPart {
private Semester semester;
private Specialty specialty;
+
List courses = new ArrayList();
public CourseScheduleView() {
+
}
public void createPartControl(Composite parent) {
@@ -167,6 +173,7 @@ public class CourseScheduleView extends ViewPart {
@Override
public void handleEvent(Event event) {
+ System.out.println(semester.getId());
TableItem[] selections = table.getSelection();
if (selections.length > 0) {
modifyItem.setEnabled(true);
@@ -182,6 +189,9 @@ public class CourseScheduleView extends ViewPart {
initSemesterCombo();
// ///////////////
refreshData();
+
+
+
}
@Override
@@ -212,6 +222,7 @@ public class CourseScheduleView extends ViewPart {
schedule.setSpecialtyId(specialty.getId());
schedule.setSemesterId(semester.getId());
scheduleService.insert(schedule);
+
refreshData();
} else {
MessageDialog.openConfirm(PlatformUI.getWorkbench().getDisplay()
@@ -280,5 +291,39 @@ public class CourseScheduleView extends ViewPart {
}
tableViewer.setInput(courses);
}
+ public Semester getSemester() {
+ return semester;
+ }
+ public Specialty getSpecialty() {
+ return specialty;
+ }
+
+ @Override
+ public void addSelectionChangedListener(ISelectionChangedListener listener) {
+ // TODO Auto-generated method stub
+
+
+ }
+
+ @Override
+ public ISelection getSelection() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void removeSelectionChangedListener(ISelectionChangedListener listener) {
+ // TODO Auto-generated method stub
+
+
+
+ }
+
+ @Override
+ public void setSelection(ISelection selection) {
+ // TODO Auto-generated method stub
+
+ }
+
}
\ No newline at end of file
diff --git a/src/config/applicationContext.xml b/src/config/applicationContext.xml
index 91445988a57839775aec620796b150865afd9a3f..e5f07d1f0a34465cb50a8c00fab16cc6f83c6c8c 100644
--- a/src/config/applicationContext.xml
+++ b/src/config/applicationContext.xml
@@ -14,7 +14,7 @@
http://www.springframework.org/schema/cache/spring-cache.xsd">
-
+