Permalink
Browse files

Messed around with ViewAssessmentHandler and rtslHandler to try to get

each student's assessment list to display properly.  Still doesn't quite
work.
  • Loading branch information...
1 parent 57972cc commit 0f1f7d2abda76db8cafb8454654fbbe5ff2259cf Helen Wauck committed May 10, 2012
Oops, something went wrong.
@@ -3,7 +3,6 @@
import java.util.ArrayList;
import java.util.List;
-import edu.gac.ATEP.client.StudentPanel.rtslHandler;
import edu.gac.ATEP.shared.Assessment;
import edu.gac.ATEP.shared.AssessmentTempStore;
import edu.gac.ATEP.shared.AssessmentTempStoreAsync;
@@ -49,8 +48,11 @@
private VerticalPanel assessmentInfoPanel;
private VerticalPanel mainPanel;
private VerticalPanel viewAssessmentsPanel;
+ private Button rtslButton;
+ public rtslHandler rtsl;
private Long nextID = 1L; //TODO change if appropriate
+
private Label updatingLabel;
private Label failureLabel;
/**
@@ -90,6 +92,12 @@ public void onModuleLoad() {
mainPanel.add(errorLabel);
viewAssessmentsPanel = new VerticalPanel();
+ assessmentDatabasePanel = new VerticalPanel();
+ assessmentDatabasePanel.setVisible(false);
+ rtslButton = new Button("Return to Student List");
+ rtsl = new rtslHandler(mainPanel, viewAssessmentsPanel, assessmentDatabasePanel);
+ rtslButton.addClickHandler(rtsl);
+ viewAssessmentsPanel.add(rtslButton);
//set up updating and failure labels
final HorizontalPanel statusPanel = new HorizontalPanel();
@@ -187,23 +195,27 @@ public void onSuccess(List<Student> studentList) {
// private void constructStudentPanels(List<Student> newStudentList) {
// VerticalPanel studentInfoPanel;
- assessmentDatabasePanel = new VerticalPanel();
- assessmentDatabasePanel.setVisible(false);
+
int studentIndex = 0;
- for(Student s : studentList){
- s.setIndex(studentIndex);
- studentIndex++;
- StudentPanel newStudPanel = new StudentPanel(s, mainPanel, viewAssessmentsPanel, assessmentDatabasePanel);
- ArrayList<Assessment> assessments = s.getMyAssessments();
- for(Assessment a : assessments) {
- newStudPanel.populatePanel(a);
- }
- studentListPanel.add(newStudPanel, s.getName());
+ for(Student s : studentList){
+ s.setIndex(studentIndex);
+ studentIndex++;
+ StudentPanel newStudPanel = new StudentPanel(s, mainPanel, viewAssessmentsPanel, assessmentDatabasePanel);
+ ArrayList<Assessment> assessments = s.getMyAssessments();
+ for(Assessment a : assessments) {
+ newStudPanel.populatePanel(a);
}
-
+ studentListPanel.add(newStudPanel, s.getName());
}
+
+
+
+ }
+
+
+
//TODO We need to figure out how we want to handle updates vs. displaying the updated list.
// As you can see from Max's email, if we leave the project how it currently is, sometimes
// on the first load, it won't display the students added to the database on startup. This
@@ -12,6 +12,7 @@
import com.google.gwt.user.client.ui.StackPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Label;
+
import edu.gac.ATEP.shared.Assessment;
import edu.gac.ATEP.shared.Student;
import edu.gac.ATEP.shared.Category;
@@ -20,16 +21,16 @@
public class StudentPanel extends VerticalPanel{
private Student stud;
- private VerticalPanel panel1;
+ private VerticalPanel mainPanel;
private VerticalPanel viewAssessmentsPanel;
private VerticalPanel databasePanel;
private StackPanel assessmentListPanel;
ArrayList<Assessment> assessments;
- public StudentPanel(Student stud, VerticalPanel panel1, VerticalPanel viewAssessmentsPanel, VerticalPanel databasePanel){
+ public StudentPanel(Student stud, VerticalPanel mainPanel, VerticalPanel viewAssessmentsPanel, VerticalPanel databasePanel){
super();
this.stud = stud;
- this.panel1 = panel1;
+ this.mainPanel = mainPanel;
this.viewAssessmentsPanel = viewAssessmentsPanel;
this.databasePanel = databasePanel;
assessmentListPanel = new StackPanel();
@@ -38,39 +39,7 @@ public StudentPanel(Student stud, VerticalPanel panel1, VerticalPanel viewAssess
}
- class rtslHandler implements ClickHandler {
- private StudentPanel studPanel;
-
- public rtslHandler(StudentPanel studPanel){
- this.studPanel = studPanel;
- }
- //fired when the user clicks on the rtslButton.
- public void onClick(ClickEvent event){
- panel1.setVisible(true);
- viewAssessmentsPanel.setVisible(false);
- databasePanel.insert(viewAssessmentsPanel.getWidget(1), studPanel.stud.getIndex());
- databasePanel.remove(studPanel.stud.getIndex() + 1);
- viewAssessmentsPanel.remove(databasePanel.getWidget(studPanel.stud.getIndex()));
- }
- }
-
-///////////////////////////////Create a handler for the ViewAssessmentButton\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
- class ViewAssessmentsHandler implements ClickHandler{
- private StudentPanel studPanel;
-
- public ViewAssessmentsHandler(StudentPanel studPanel) {
- this.studPanel = studPanel;
-
- }
-
- //Fired when the user clicks on the ViewAssessmentButton.
- public void onClick(ClickEvent event){
- panel1.setVisible(false);
- viewAssessmentsPanel.setVisible(true);
- viewAssessmentsPanel.add(databasePanel.getWidget(studPanel.stud.getIndex()));
- }
-
- }
+
//Send the name selected from the student list to the server and wait for a response.
public void populatePanel(Assessment assessmentToPopulate) {
@@ -109,17 +78,17 @@ public void populatePanel(Assessment assessmentToPopulate) {
}
+ public Student getStudent() {
+ return stud;
+ }
+
private void initGUI() {
this.add(new Label("Year in program: " + stud.getClassYear()));
this.add(new Button("Delete this student"));
AssessmentButton viewButton = new AssessmentButton("View Assessments", stud);
this.add(viewButton);
- ViewAssessmentsHandler viewAssessment = new ViewAssessmentsHandler(this);
+ ViewAssessmentsHandler viewAssessment = new ViewAssessmentsHandler(this,mainPanel,viewAssessmentsPanel,databasePanel);
viewButton.addClickHandler(viewAssessment);
- Button rtslButton = new Button("Return to Student List");
- rtslHandler rtsl = new rtslHandler(this);
- rtslButton.addClickHandler(rtsl);
- viewAssessmentsPanel.add(rtslButton);
}
}
@@ -1,22 +0,0 @@
-package edu.gac.ATEP.client;
-
-import com.google.gwt.event.dom.client.ClickEvent;
-import com.google.gwt.event.dom.client.ClickHandler;
-import com.google.gwt.user.client.ui.VerticalPanel;
-
-public class ViewAssessmentHandler implements ClickHandler{
-
- //Fired when the user clicks on the ViewAssessmentButton.
- public void onClick(ClickEvent event){
- /*mainPanel.setVisible(false);
- assessmentPanel.setVisible(true);*/
- //VerticalPanel populatedPanel = new VerticalPanel();
- }
-
- //Send the name selected from the student list to the server and wait for a response.
- private void sendNameToServer() {
- // TODO we may need this method later when a student name
- // is selected in order to retrieve their info
- }
-}
-
@@ -0,0 +1,32 @@
+package edu.gac.ATEP.client;
+
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.user.client.ui.VerticalPanel;
+
+public class ViewAssessmentsHandler implements ClickHandler{
+ private StudentPanel studPanel;
+ private VerticalPanel mainPanel;
+ private VerticalPanel viewAssessmentsPanel;
+ private VerticalPanel databasePanel;
+
+ public ViewAssessmentsHandler(StudentPanel sP, VerticalPanel mP, VerticalPanel vAP, VerticalPanel dbP) {
+ studPanel = sP;
+ mainPanel = mP;
+ viewAssessmentsPanel = vAP;
+ databasePanel = dbP;
+
+ }
+
+ //Fired when the user clicks on the ViewAssessmentButton.
+ public void onClick(ClickEvent event){
+ mainPanel.setVisible(false);
+ //rtsl.setStudPanel(studPanel);
+ System.out.println(studPanel.getStudent().getName());
+ viewAssessmentsPanel.setVisible(true);
+ System.out.println(databasePanel.getWidgetCount());
+ viewAssessmentsPanel.add(databasePanel.getWidget(studPanel.getStudent().getIndex()));
+ }
+
+}
+
@@ -0,0 +1,40 @@
+package edu.gac.ATEP.client;
+
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.user.client.ui.VerticalPanel;
+
+public class rtslHandler implements ClickHandler {
+ private StudentPanel studPanel;
+ private VerticalPanel mainPanel;
+ private VerticalPanel viewAssessmentsPanel;
+ private VerticalPanel databasePanel;
+
+ public rtslHandler(VerticalPanel mP, VerticalPanel vAP, VerticalPanel dbP){
+ studPanel = null;
+ mainPanel = mP;
+ viewAssessmentsPanel = vAP;
+ databasePanel = dbP;
+ }
+
+ public rtslHandler(StudentPanel sP, VerticalPanel mP, VerticalPanel vAP, VerticalPanel dbP){
+ studPanel = sP;
+ mainPanel = mP;
+ viewAssessmentsPanel = vAP;
+ databasePanel = dbP;
+ }
+
+ public void setStudPanel(StudentPanel sP){
+ studPanel = sP;
+ }
+ //fired when the user clicks on the rtslButton.
+ public void onClick(ClickEvent event){
+ //System.out.println("Returned to Student List: Panel = " + studPanel.getStudent().getName());
+ mainPanel.setVisible(true);
+ viewAssessmentsPanel.setVisible(false);
+ databasePanel.insert(viewAssessmentsPanel.getWidget(1), studPanel.getStudent().getIndex());
+ databasePanel.remove(studPanel.getStudent().getIndex());
+ viewAssessmentsPanel.remove(viewAssessmentsPanel.getWidget(1));
+
+ }
+}

0 comments on commit 0f1f7d2

Please sign in to comment.