added task details view, cleaned up some UI issues

Jonathan Bell [2011-10-10 21:23:53]
added task details view, cleaned up some UI issues
Filename
halo-se-common/src/edu/columbia/cs/psl/halo/entity/User.java
halo-se-feature/feature.xml
halo-se/src/edu/columbia/cs/psl/halo/client/views/DashboardView.java
halo-se/src/edu/columbia/cs/psl/halo/client/views/LoginComposite.java
halo-se/src/edu/columbia/cs/psl/halo/client/views/QuestHUD.java
halo-update-site/artifacts.jar
halo-update-site/content.jar
halo-update-site/plugins/edu.columbia.cs.psl.halo.client_1.0.0.201110091506.jar
halo-update-site/plugins/edu.columbia.cs.psl.halo.client_1.0.0.201110091615.jar
halo-update-site/plugins/edu.columbia.cs.psl.halo.client_1.0.0.201110092339.jar
halo-update-site/plugins/edu.columbia.cs.psl.halo.client_1.0.0.201110092345.jar
halo-update-site/site.xml
diff --git a/halo-se-common/src/edu/columbia/cs/psl/halo/entity/User.java b/halo-se-common/src/edu/columbia/cs/psl/halo/entity/User.java
index 7b0ebdc..1c52a01 100644
--- a/halo-se-common/src/edu/columbia/cs/psl/halo/entity/User.java
+++ b/halo-se-common/src/edu/columbia/cs/psl/halo/entity/User.java
@@ -47,6 +47,14 @@ public class User extends LazyCycleBreaker implements Serializable {
 	private String facebookSessionKey;
 	private boolean hasFBkey;

+	@Override
+	public int hashCode() {
+		return new Integer(id).hashCode();
+	}
+	@Override
+	public boolean equals(Object obj) {
+		return (obj instanceof User && ((User) obj).getId() == getId());
+	}
 	public User() {

 	}
diff --git a/halo-se-feature/feature.xml b/halo-se-feature/feature.xml
index af9cc75..ac9ae0d 100644
--- a/halo-se-feature/feature.xml
+++ b/halo-se-feature/feature.xml
@@ -2,7 +2,7 @@
 <feature
       id="edu.columbia.cs.psl.halo.client"
       label="HALO SE Client Environment"
-      version="1.0.1.1">
+      version="1.0.1.3">

    <description url="http://www.example.com/description">
       [Enter Feature Description here.]
diff --git a/halo-se/src/edu/columbia/cs/psl/halo/client/views/DashboardView.java b/halo-se/src/edu/columbia/cs/psl/halo/client/views/DashboardView.java
index 28393e9..56b5bad 100644
--- a/halo-se/src/edu/columbia/cs/psl/halo/client/views/DashboardView.java
+++ b/halo-se/src/edu/columbia/cs/psl/halo/client/views/DashboardView.java
@@ -1,5 +1,8 @@
 package edu.columbia.cs.psl.halo.client.views;

+import java.util.Timer;
+import java.util.TimerTask;
+
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.custom.ScrolledComposite;
 import org.eclipse.swt.custom.StackLayout;
@@ -11,6 +14,7 @@ import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchPage;
 import org.eclipse.ui.part.ViewPart;

 import edu.columbia.cs.psl.halo.HALOServiceFactory;
@@ -71,7 +75,7 @@ public class DashboardView extends ViewPart {
 		parentLayout.topControl = loginComposite;
 		parent.layout(true);
 	}
-
+	private Timer refreshTimer;
 	void loggedIn() {
 		parentLayout.topControl = dashboardScroller;
 		parent.layout();
@@ -80,10 +84,24 @@ public class DashboardView extends ViewPart {
 		Rectangle r = dashboardScroller.getClientArea();
 		dashboardScroller.setMinSize(dashboardComposite.computeSize(
 				r.width, SWT.DEFAULT));
-
+		refreshTimer = new Timer(true);
+		refreshTimer.schedule(new TimerTask() {
+
+			@Override
+			public void run() {
+				updateWindow();
+				IWorkbenchPage page = getSite()
+						.getPage();
+				QuestHUD view = (QuestHUD) page
+						.findView(QuestHUD.ID);
+				view.updateQuests();
+			}
+		}, 30000, 30000);
 	}

 	void loggedOut() {
+		refreshTimer.cancel();
+		refreshTimer = null;
 		parentLayout.topControl = loginComposite;
 		parent.layout(true);
 	}
diff --git a/halo-se/src/edu/columbia/cs/psl/halo/client/views/LoginComposite.java b/halo-se/src/edu/columbia/cs/psl/halo/client/views/LoginComposite.java
index cb29821..435e2cb 100644
--- a/halo-se/src/edu/columbia/cs/psl/halo/client/views/LoginComposite.java
+++ b/halo-se/src/edu/columbia/cs/psl/halo/client/views/LoginComposite.java
@@ -3,6 +3,8 @@ package edu.columbia.cs.psl.halo.client.views;
 import java.io.File;
 import java.net.MalformedURLException;
 import java.security.PrivilegedAction;
+import java.util.Timer;
+import java.util.TimerTask;

 import javax.security.auth.Subject;
 import javax.security.auth.login.LoginException;
@@ -265,7 +267,8 @@ public class LoginComposite extends Composite {
 		data.horizontalSpan = 2;
 		fTextPassword.setLayoutData(data);
 	}
-
+
+
 	private String rememberToken = null;
 	private void handleButtonOKWidgetSelected() {
 		final String username = fTextUsername.getText();
@@ -301,6 +304,7 @@ public class LoginComposite extends Composite {
 					}
 					if (res) {
 						rememberToken =  HALOServiceFactory.getInstance().getUserSvc().getRememberMeToken();
+
 						return Status.OK_STATUS;
 					} else {
 						return Status.CANCEL_STATUS;
diff --git a/halo-se/src/edu/columbia/cs/psl/halo/client/views/QuestHUD.java b/halo-se/src/edu/columbia/cs/psl/halo/client/views/QuestHUD.java
index d6ecfc1..6bed3c7 100644
--- a/halo-se/src/edu/columbia/cs/psl/halo/client/views/QuestHUD.java
+++ b/halo-se/src/edu/columbia/cs/psl/halo/client/views/QuestHUD.java
@@ -251,7 +251,7 @@ public class QuestHUD extends ViewPart {
 			questTitle.setText("Batman's Quest, the really long one.");
 			questTitle.setLayoutData(new TableWrapData());
 			FontData[] fD = questTitle.getFont().getFontData();
-			fD[0].setHeight(24);
+			fD[0].setHeight(16);
 			fD[0].setStyle(SWT.BOLD);
 			questTitle.setFont(new Font(parent.getDisplay(), fD[0]));

@@ -261,13 +261,13 @@ public class QuestHUD extends ViewPart {
 			TableWrapData data = new TableWrapData();
 //			data.widthHint = this.getBounds().width - 20;
 			questDueDate.setLayoutData(data);
-			fD[0].setHeight(16);
+			fD[0].setHeight(12);
 			fD[0].setStyle(SWT.BOLD);
 			questDueDate.setFont(new Font(parent.getDisplay(), fD[0]));

 			backgroundHeader = new Label(this, SWT.NONE);
 			backgroundHeader.setText("Background");
-			fD[0].setHeight(16);
+			fD[0].setHeight(13);
 			fD[0].setStyle(SWT.BOLD);
 			backgroundHeader.setFont(new Font(parent.getDisplay(), fD[0]));

@@ -285,7 +285,7 @@ public class QuestHUD extends ViewPart {

 			objectivesHeader = new Label(this, SWT.NONE);
 			objectivesHeader.setText("Objectives");
-			fD[0].setHeight(16);
+			fD[0].setHeight(13);
 			fD[0].setStyle(SWT.BOLD);
 			objectivesHeader.setFont(new Font(parent.getDisplay(), fD[0]));

@@ -298,28 +298,33 @@ public class QuestHUD extends ViewPart {
 			objectivesBody.setLayoutData(data);
 			fD[0].setStyle(SWT.NORMAL);
 			objectivesBody.setFont(new Font(parent.getDisplay(), fD[0]));
-
-//			parent.addListener(SWT.Resize, new Listener() {
-//				public void handleEvent(Event event) {
-//					int prefWidth = getShell().getBounds().width - 40;
-//					// System.out.println("Pref is " + prefWidth);
-////					TableWrapData data = (TableWrapData) questBackground.getLayoutData();
-////					data.widthHint = prefWidth;
-////					questBackground.setLayoutData(data);
-////					objectivesBody.setLayoutData(data);
-////					data = (GridData) questDueDate.getLayoutData();
-////					data.widthHint = prefWidth;
-////					questDueDate.setLayoutData(data);
-//					getShell().layout(true);
-//				}
-//			});
 		}
-
+		public void setTask(Task t)
+		{
+			questTitle.setText(t.getName());
+			questBackground.setText(t.getDescription());
+			backgroundHeader.setText("Task Details");
+			questDueDate.setText("(Part of " + ((Quest) t.getQuest().getRef()).getName() +")");
+
+			String objectives = "";
+			objectivesHeader.setText("Quest Background");
+			objectivesBody.setText(((Quest) t.getQuest().getRef()).getDescription());
+			refreshLayout();
+		}
+		private void refreshLayout()
+		{
+			setLayout(new TableWrapLayout());
+			Rectangle r = questDetailsScroller.getClientArea();
+			questDetailsScroller.setMinSize(questDetails.computeSize(r.width,
+					SWT.DEFAULT));
+			getParent().layout(true,true);
+		}
 		public void setQuest(QuestWrapper w) {
 			questTitle.setText(w.getQuest().getName());
 			questDueDate.setText("(Part of " + w.getAssignment().getTitle()
 					+ ", due " + w.getDueStrHuman() + ")");
 			questBackground.setText(w.getQuest().getDescription());
+			backgroundHeader.setText("Background");

 			String objectives = "";

@@ -329,18 +334,14 @@ public class QuestHUD extends ViewPart {
 			objectivesHeader.setText("Objectives");
 			objectivesBody.setText(objectives);
 			objectivesBody.setLayoutData(new TableWrapData());
-			setLayout(new TableWrapLayout());
-			parent.notifyListeners(SWT.Resize, new Event());
-			Rectangle r = questDetailsScroller.getClientArea();
-			questDetailsScroller.setMinSize(questDetails.computeSize(r.width,
-					SWT.DEFAULT));
-			getParent().layout(true);
+			refreshLayout();

 		}
 		public void setAssignment(Assignment w) {
 			questTitle.setText(w.getTitle());
 			questDueDate.setText("Due " + QuestWrapper.getDueStrHuman(w));
 			questBackground.setText(w.getDescription());
+			backgroundHeader.setText("Background");

 			String objectives = "";
 			objectivesHeader.setText("Quests");
@@ -348,10 +349,6 @@ public class QuestHUD extends ViewPart {
 				objectives += t.getName() + "\n";
 			}
 			objectivesBody.setText(objectives);
-			Rectangle r = questDetailsScroller.getClientArea();
-			questDetailsScroller.setMinSize(questDetails.computeSize(r.width,
-					SWT.DEFAULT));
-			parent.notifyListeners(SWT.Resize, new Event());
 		}
 	}

@@ -535,7 +532,7 @@ public class QuestHUD extends ViewPart {
 	private QuestDetails questDetails;
 	private ScrolledComposite questDetailsScroller;

-	HashMap<Quest, QuestWrapper> quests;
+	HashMap<Integer, QuestWrapper> quests;
 	Tree questsTree;
 	TreeViewer questsViewer;
 	private Boolean updatingFlag = Boolean.FALSE;
@@ -589,9 +586,9 @@ public class QuestHUD extends ViewPart {
 			qp.setUser(HALOServiceFactory.getInstance().getMe());
 			cachedProgress.put(t, qp);

-			questsViewer.refresh();
+			questsViewer.refresh(true);
 			questsViewer.expandAll();
-
+
 			Activator.logBackground("TaskCompleteConfirmed", "" + t.getId());
 			Job j = new Job("Marking task completed") {

@@ -670,7 +667,6 @@ public class QuestHUD extends ViewPart {
 									{
 										completeTask(t);
 									}
-									questsViewer.refresh();
 								}
 							}
 						}
@@ -716,10 +712,25 @@ public class QuestHUD extends ViewPart {
 									.getSelection();
 							QuestWrapper qw = null;
 							if ((selection.getFirstElement()) instanceof Quest) {
-								qw = quests.get(((Quest) selection.getFirstElement()));
+//								System.out.println(((Quest) selection.getFirstElement()).getId());
+								qw = quests.get(((Quest) selection.getFirstElement()).getId());
+								if(qw == null)
+								{
+									questsViewer.setSelection(null);
+									return;
+								}
+								Activator.logBackground("QuestHUDQuestOrTaskSelected", "" + qw.getQuest().getId());
+								detailsLayout.topControl = questDetailsScroller;
+								questDetails.setQuest(qw);
+								refreshLayout();
 							}
 							else if((selection.getFirstElement()) instanceof Task) {
-								qw = quests.get(((Quest) ((Task) selection.getFirstElement()).getQuest().getRef()));
+//								qw = quests.get(((Quest) ((Task) selection.getFirstElement()).getQuest().getRef()));
+								Task t = ((Task) selection.getFirstElement());
+								Activator.logBackground("QuestHUDTaskSelected", "" + t.getId());
+								detailsLayout.topControl = questDetailsScroller;
+								questDetails.setTask(t);
+								refreshLayout();
 							}
 							else if((selection.getFirstElement()) instanceof Assignment) {

@@ -727,21 +738,7 @@ public class QuestHUD extends ViewPart {
 								Activator.logBackground("QuestHUDAssignmentSelected", "" + a.getId());
 								detailsLayout.topControl = questDetailsScroller;
 								questDetails.setAssignment(a);
-								detailsArea.layout(true);
-								parent.notifyListeners(SWT.Resize, new Event());
-								parent.layout(true);
-								detailsArea.layout(true);
-								questDetailsScroller.layout(true,true);
-							}
-							if(qw != null){
-								Activator.logBackground("QuestHUDQuestOrTaskSelected", "" + qw.getQuest().getId());
-								detailsLayout.topControl = questDetailsScroller;
-								questDetails.setQuest(qw);
-								detailsArea.layout(true);
-								parent.notifyListeners(SWT.Resize, new Event());
-								parent.layout(true);
-								detailsArea.layout(true);
-								questDetailsScroller.layout(true,true);
+								refreshLayout();
 							}
 						}
 					}
@@ -749,7 +746,14 @@ public class QuestHUD extends ViewPart {

 		updateQuests();
 	}
-
+	void refreshLayout()
+	{
+		detailsArea.layout(true,true);
+		parent.notifyListeners(SWT.Resize, new Event());
+		parent.layout(true,true);
+		detailsArea.layout(true,true);
+		questDetailsScroller.layout(true,true);
+	}
 	void loggedIn() {
 		this.layout.topControl = loggedInPanel;
 		parent.layout(true);
@@ -775,7 +779,7 @@ public class QuestHUD extends ViewPart {
 		updateQuests();
 	}

-	private void updateQuests() {
+	public void updateQuests() {
 		synchronized (updatingFlag) {
 			if (updatingFlag)
 				return;
@@ -787,13 +791,13 @@ public class QuestHUD extends ViewPart {

 					@Override
 					protected IStatus run(IProgressMonitor monitor) {
-						quests = new HashMap<Quest,QuestWrapper>();
-						HashMap<Quest, QuestProgress> progress = new HashMap<Quest, QuestProgress>();
+						quests = new HashMap<Integer,QuestWrapper>();
+						HashMap<Integer, QuestProgress> progress = new HashMap<Integer, QuestProgress>();
 						if (HALOServiceFactory.getInstance().getUserSvc()
 								.getMyProgress() != null)
 							for (QuestProgress p : HALOServiceFactory
 									.getInstance().getUserSvc().getMyProgress()) {
-								progress.put(p.getQuest(), p);
+								progress.put(p.getQuest().getId(), p);
 								cachedProgress.put(p.getTask(), p);
 							}
 						for (Enrollment e : HALOServiceFactory.getInstance()
@@ -807,8 +811,8 @@ public class QuestHUD extends ViewPart {
 											.getQuestsFor(a)) {
 										QuestWrapper qw = new QuestWrapper(q,
 												a, e.getCourse(),
-												progress.get(q));
-										quests.put(q,qw);
+												progress.get(q.getId()));
+										quests.put(q.getId(),qw);
 									}
 								}
 							}
@@ -817,7 +821,7 @@ public class QuestHUD extends ViewPart {

 							@Override
 							public void run() {
-								questsViewer.refresh();
+								questsViewer.refresh(true);
 								questsViewer.expandAll();
 								updatingFlag = false;
 							}
diff --git a/halo-update-site/artifacts.jar b/halo-update-site/artifacts.jar
index c2593af..003708c 100644
Binary files a/halo-update-site/artifacts.jar and b/halo-update-site/artifacts.jar differ
diff --git a/halo-update-site/content.jar b/halo-update-site/content.jar
index 9038142..56ba54b 100644
Binary files a/halo-update-site/content.jar and b/halo-update-site/content.jar differ
diff --git a/halo-update-site/plugins/edu.columbia.cs.psl.halo.client_1.0.0.201110091506.jar b/halo-update-site/plugins/edu.columbia.cs.psl.halo.client_1.0.0.201110091506.jar
deleted file mode 100644
index c74ae4e..0000000
Binary files a/halo-update-site/plugins/edu.columbia.cs.psl.halo.client_1.0.0.201110091506.jar and /dev/null differ
diff --git a/halo-update-site/plugins/edu.columbia.cs.psl.halo.client_1.0.0.201110091615.jar b/halo-update-site/plugins/edu.columbia.cs.psl.halo.client_1.0.0.201110091615.jar
deleted file mode 100644
index 275377b..0000000
Binary files a/halo-update-site/plugins/edu.columbia.cs.psl.halo.client_1.0.0.201110091615.jar and /dev/null differ
diff --git a/halo-update-site/plugins/edu.columbia.cs.psl.halo.client_1.0.0.201110092339.jar b/halo-update-site/plugins/edu.columbia.cs.psl.halo.client_1.0.0.201110092339.jar
deleted file mode 100644
index 4e84e9e..0000000
Binary files a/halo-update-site/plugins/edu.columbia.cs.psl.halo.client_1.0.0.201110092339.jar and /dev/null differ
diff --git a/halo-update-site/plugins/edu.columbia.cs.psl.halo.client_1.0.0.201110092345.jar b/halo-update-site/plugins/edu.columbia.cs.psl.halo.client_1.0.0.201110092345.jar
deleted file mode 100644
index f6e5929..0000000
Binary files a/halo-update-site/plugins/edu.columbia.cs.psl.halo.client_1.0.0.201110092345.jar and /dev/null differ
diff --git a/halo-update-site/site.xml b/halo-update-site/site.xml
index 91d9231..a942e6f 100644
--- a/halo-update-site/site.xml
+++ b/halo-update-site/site.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <site>
-   <feature url="features/edu.columbia.cs.psl.halo.client_1.0.1.1.jar" id="edu.columbia.cs.psl.halo.client" version="1.0.1.1">
+   <feature url="features/edu.columbia.cs.psl.halo.client_1.0.1.3.jar" id="edu.columbia.cs.psl.halo.client" version="1.0.1.3">
       <category name="HALO"/>
    </feature>
    <category-def name="HALO" label="HALO SE"/>