Revert "Merge branch 'dev' of https://github.com/Acstylos/wpi-suite into feature/colors4"
This reverts commit 99a07ff56818a519fec75f4cc90ba5550ea9a39b, reversing
changes made to aa3cdb4212d2111d3f122a8584071dd496553139.
diff --git a/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/model/ActivityModel.java b/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/model/ActivityModel.java
index fe7ef77..8dc8370 100644
--- a/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/model/ActivityModel.java
+++ b/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/model/ActivityModel.java
@@ -225,19 +225,5 @@
// TODO Auto-generated method stub
return null;
}
-
- /**
- * Checks if two models are the same
- *
- * @param that
- * the model to be compared
- * @return if it is equal or not
- */
- public Boolean isEqual(ActivityModel that) {
- return (this.isAutogen == that.isAutogen
- && this.activity.equals(that.activity)
- && this.date.equals(that.date)
- && this.id == that.id
- && this.userId == that.userId);
- }
+
}
diff --git a/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/model/TaskModel.java b/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/model/TaskModel.java
index d6bc83a..f2a3402 100644
--- a/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/model/TaskModel.java
+++ b/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/model/TaskModel.java
@@ -14,7 +14,6 @@
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
-import java.util.Calendar;
import java.util.Date;
import java.util.List;
@@ -36,10 +35,8 @@
private int estimatedEffort;
private int actualEffort;
private Date dueDate;
- private Date dateCreated;
private int status;
private Color labelColor;
- private boolean isArchived;
/**
* Constructor for a default Task object
@@ -56,10 +53,6 @@
actualEffort = 0;
status = 1;
labelColor=null;
- isArchived = false;
- dueDate = null;
- Calendar cal = Calendar.getInstance();
- dateCreated = cal.getTime();
}
/**
@@ -90,7 +83,6 @@
this.dueDate = dueDate;
this.status = status;
this.labelColor=null;
- this.isArchived = false;
}
/**
@@ -203,7 +195,6 @@
this.status = other.getStatus();
this.activityIds = other.getActivityIds();
this.labelColor=other.getLabelColor();
- this.isArchived = other.getIsArchived();
}
/**
@@ -403,27 +394,5 @@
public void addActivityID(int id) {
activityIds.add(id);
}
-
-
- /**
- * @return the date task was created
- */
- public Date getDateCreated() {
- return dateCreated;
- }
-
- /**
- * @return if task is archived
- */
- public boolean getIsArchived() {
- return isArchived;
- }
-
- /**
- * @param isArchived boolean indicating if task is archived
- */
- public void setIsArchived(boolean isArchived) {
- this.isArchived = isArchived;
- }
}
diff --git a/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/model/WorkflowModel.java b/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/model/WorkflowModel.java
index 633abfb..3f5e909 100644
--- a/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/model/WorkflowModel.java
+++ b/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/model/WorkflowModel.java
@@ -17,41 +17,39 @@
/**
* Workflow is the container for the buckets
- *
* @author TheFloorIsJava
*
*/
-public class WorkflowModel extends AbstractModel {
+public class WorkflowModel extends AbstractModel{
private int id;
private String title;
private ArrayList<Integer> bucketIds;
-
+
/**
* Default constructor
*/
- public WorkflowModel() {
- this(-1, "");
+ public WorkflowModel(){
+ this(-1, "");
}
/**
* Constructor for the workflow model
- *
* @param title
* @param ID
*/
- public WorkflowModel(int ID, String title) {
- this.id = ID;
- this.title = title;
- this.bucketIds = new ArrayList<>();
+ public WorkflowModel(int ID, String title){
+ this.id = ID;
+ this.title=title;
+ this.bucketIds=new ArrayList<>();
}
-
+
/**
* Will implement later
*/
@Override
public void save() {
- // TODO Auto-generated method stub
+ // TODO Auto-generated method stub
}
@@ -60,36 +58,32 @@
*/
@Override
public void delete() {
- // TODO Auto-generated method stub
+ // TODO Auto-generated method stub
}
-
+
/**
* @return The Json string for the object
*/
@Override
- public String toJson() {
- Gson gson = new Gson();
- return gson.toJson(this, WorkflowModel.class);
+ public String toJson(){
+ Gson gson = new Gson();
+ return gson.toJson(this, WorkflowModel.class);
}
-
+
/**
* Parses a Json string to an object
- *
- * @param json
- * the json-encoded WorkflowModel to deserialize
+ * @param json the json-encoded WorkflowModel to deserialize
* @return the WorkflowModel contained in the given JSON
*/
public static WorkflowModel fromJson(String json) {
final Gson parser = new Gson();
return parser.fromJson(json, WorkflowModel.class);
}
-
+
/**
* Parses a Json string to an array of objects
- *
- * @param json
- * The Json string for the array of BucketModels
+ * @param json The Json string for the array of BucketModels
* @return An array of BucketModels parsed from the Json array
*/
public static WorkflowModel[] fromJSONArray(String json) {
@@ -98,92 +92,67 @@
}
/**
- * determines if the other object is of class WorkFlowModel
- * @param o other object
- *
+ * Will implement later
* @see edu.wpi.cs.wpisuitetng.modules.Model#identify(java.lang.Object)
*/
@Override
public Boolean identify(Object o) {
- try{
- if(this.getClass().equals(((WorkflowModel) o).getClass()))
- return true;
- }
- catch (Exception e){
- return false;
- }
- return null;
+ // TODO Auto-generated method stub
+ return null;
}
-
+
/**
* gets the list of bucket IDs
- *
* @return the List of bucket IDs
*/
- public ArrayList<Integer> getBucketIds() {
- return this.bucketIds;
+ public ArrayList<Integer> getBucketIds(){
+ return this.bucketIds;
}
-
+
/**
* Sets the list of bucket IDs
- *
- * @param bucketIDs
- * The list of bucketIDs
+ * @param bucketIDs The list of bucketIDs
*/
public void setBucketIds(ArrayList<Integer> bucketIds) {
- this.bucketIds = bucketIds;
+ this.bucketIds = bucketIds;
}
/**
* @return The title of the workflow
*/
- public String getTitle() {
- return this.title;
+ public String getTitle(){
+ return this.title;
}
/**
- * @param title
- * The title of the workflow to be set
+ * @param title The title of the workflow to be set
*/
- public void setTitle(String title) {
- this.title = title;
+ public void setTitle(String title){
+ this.title = title;
}
-
- /**
- * Determines if this WorkflowModel is equal to that WorkflowModel
- * @param that the other workflowModel
- * @return boolean, true if the id, title, and bucketIds are equal. otherwise false
- */
- public boolean equals(WorkflowModel that) {
- return (this.id == that.id && this.title.equals(that.title) && this.bucketIds
- .equals(that.bucketIds));
- }
-
+
/**
* @return The ID of the workflow
*/
- public int getId() {
- return this.id;
+ public int getId(){
+ return this.id;
}
/**
- * @param ID
- * The ID of the workflow to be set
+ * @param ID The ID of the workflow to be set
*/
- public void setId(int id) {
- this.id = id;
+ public void setId(int id){
+ this.id = id;
}
-
+
/**
- * Copies all of the values from the given WorkflowModel to this
- * WorkflowModel excluding the Id.
- *
- * @param toCopyFrom
- * the BucketModel to copy from.
- */
- public void copyFrom(WorkflowModel toCopyFrom) {
- this.id = toCopyFrom.id;
- this.title = toCopyFrom.title;
- this.bucketIds = toCopyFrom.bucketIds;
+ * Copies all of the values from the given WorkflowModel to this WorkflowModel
+ * excluding the Id.
+ * @param toCopyFrom the BucketModel to copy from.
+ */
+ public void copyFrom(WorkflowModel toCopyFrom) {
+ this.id = toCopyFrom.id;
+ this.title = toCopyFrom.title;
+ this.bucketIds = toCopyFrom.bucketIds;
}
}
diff --git a/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/presenter/BucketObserver.java b/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/presenter/BucketObserver.java
index 0865f6a..ae5e9ed 100644
--- a/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/presenter/BucketObserver.java
+++ b/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/presenter/BucketObserver.java
@@ -46,28 +46,28 @@
// Store the response
final ResponseModel response = iReq.getResponse();
- final BucketModel model;
- switch (iReq.getHttpMethod()) {
- case GET:
+
+ if(method == HttpMethod.GET){
+
// Parse the message
- model = BucketModel.fromJsonArray(response.getBody())[0];
- this.presenter.setModel(model);
- break;
- case POST:
+ final BucketModel[] models = BucketModel.fromJsonArray(response.getBody());
+ presenter.responseGet(models);
+ }else{
// Parse the message
- model = BucketModel.fromJson(response.getBody());
- this.presenter.responsePost(model);
- break;
- case PUT:
- // Parse the message
- model = BucketModel.fromJson(response.getBody());
- this.presenter.responsePut(model);
- break;
- case DELETE:
- // Parse the message
- model = BucketModel.fromJson(response.getBody());
- this.presenter.responseDelete(model);
- break;
+ final BucketModel model = BucketModel.fromJson(response.getBody());
+ switch (method) {
+ case GET:
+ break;
+ case POST:
+ presenter.responsePost(model);
+ break;
+ case PUT:
+ presenter.responsePut(model);
+ break;
+ case DELETE:
+ presenter.responseDelete(model);
+ break;
+ }
}
}
@@ -89,10 +89,6 @@
+ " a bucket failed.");
}
- /**
- * @param method_ The HttpMethod related to the request
- * @return The string corresponding to the specified HttpMethod
- */
private static String httpMethodToString(HttpMethod method_) {
String methodString = "";
switch (method_) {
diff --git a/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/presenter/BucketPresenter.java b/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/presenter/BucketPresenter.java
index e8e151e..16f4ea4 100644
--- a/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/presenter/BucketPresenter.java
+++ b/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/presenter/BucketPresenter.java
@@ -10,24 +10,17 @@
package edu.wpi.cs.wpisuitetng.modules.taskmanager.presenter;
import java.awt.Color;
-import java.awt.datatransfer.UnsupportedFlavorException;
-import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import javax.swing.TransferHandler;
-import javax.swing.TransferHandler.TransferSupport;
-
import edu.wpi.cs.wpisuitetng.modules.taskmanager.model.BucketModel;
import edu.wpi.cs.wpisuitetng.modules.taskmanager.model.TaskModel;
import edu.wpi.cs.wpisuitetng.modules.taskmanager.view.BucketView;
-//import edu.wpi.cs.wpisuitetng.modules.taskmanager.view.Entity;
import edu.wpi.cs.wpisuitetng.modules.taskmanager.view.Icons;
import edu.wpi.cs.wpisuitetng.modules.taskmanager.view.MainView;
import edu.wpi.cs.wpisuitetng.modules.taskmanager.view.MiniTaskView;
-import edu.wpi.cs.wpisuitetng.modules.taskmanager.presenter.TaskPresenter;
import edu.wpi.cs.wpisuitetng.modules.taskmanager.view.TaskView;
import edu.wpi.cs.wpisuitetng.modules.taskmanager.view.ViewMode;
import edu.wpi.cs.wpisuitetng.network.Network;
@@ -45,10 +38,21 @@
private BucketView view;
private BucketModel model;
- private Map<Integer, TaskPresenter> taskMap = new HashMap<Integer, TaskPresenter>();
+ private Map<Integer, TaskPresenter> taskMap;
private WorkflowPresenter workflow;
/**
+ * Constructs a BucketPresenter for the given model.
+ *
+ * @param model
+ * @param workflow
+ */
+ public BucketPresenter(BucketModel model, WorkflowPresenter workflow) {
+ this.model = model;
+ this.workflow = workflow;
+ }
+
+ /**
* Constructor for a bucket presenter
*
* @param bucketId
@@ -57,9 +61,9 @@
public BucketPresenter(int bucketId, WorkflowPresenter workflow) {
this.workflow = workflow;
this.model = new BucketModel();
+ this.taskMap = new HashMap<Integer, TaskPresenter>();
this.model.setId(bucketId);
this.view = new BucketView(this.model);
- registerCallbacks();
load();
}
@@ -84,8 +88,8 @@
request.setBody(model.toJson());
}
request.addObserver(new BucketObserver(this, method)); // add an
- // observer to
- // the response
+ // observer to
+ // the response
request.send();
}
@@ -116,16 +120,13 @@
}
this.view.setModel(this.model);
- for (int i : model.getTaskIds()) {
+ List<Integer> taskIds = model.getTaskIds();
+ for (int i : taskIds) {
if (!taskMap.containsKey(i)) {
taskMap.put(i, new TaskPresenter(i, this, ViewMode.EDITING));
}
taskMap.get(i).updateFromDatabase();
-
-
MiniTaskView miniTaskView = taskMap.get(i).getMiniView();
- miniTaskView.setModel(taskMap.get(i).getModel());
-
// white does no setBackground to panel.
if (taskMap.get(i).getModel().getLabelColor() != null) {
if (!taskMap.get(i).getModel().getLabelColor()
@@ -135,129 +136,54 @@
}
}
view.addTaskToView(miniTaskView);
- this.addMiniTaskView(taskMap.get(i).getMiniView());
-
}
- addMiniTaskstoView();
view.revalidate();
view.repaint();
-
- }
-
- /**
- * Register callbacks with the local view.
- */
- private void registerCallbacks() {
- /* Add a handler to let the user drag tasks into this bucket */
- this.view.setTransferHandler(new TransferHandler() {
- /**
- * @return true if it's a task being transfered
- */
- @Override
- public boolean canImport(TransferHandler.TransferSupport support) {
- try {
- TaskPresenter taskPresenter =
- (TaskPresenter) support.getTransferable().getTransferData(TaskPresenter.TASK_DATA_FLAVOR);
-
- /* The task can be imported into this bucket if it's not
- * already in it.
- */
- return taskPresenter.getBucket() != BucketPresenter.this;
- } catch (UnsupportedFlavorException | IOException e) {
- return false;
- }
- }
-
- /**
- * Add the task to this bucket
- */
- @Override
- public boolean importData(TransferSupport support) {
- try {
- TaskPresenter taskPresenter =
- (TaskPresenter) support.getTransferable().getTransferData(TaskPresenter.TASK_DATA_FLAVOR);
-
- BucketPresenter.this.addTask(taskPresenter.getModel().getId(), taskPresenter);
-
- return true;
- } catch (UnsupportedFlavorException | IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- return false;
- }
- });
}
/**
* Adds a new task to the bucket view, in the form of a miniTaskView
*/
- public void addNewMiniTaskToView() {
+ public void addNewTaskToView() {
TaskPresenter taskPresenter = new TaskPresenter(0, this,
ViewMode.CREATING);
- // taskPresenter.createInDatabase();
TaskModel taskModel = taskPresenter.getModel();
TaskView taskView = taskPresenter.getView();
- MainView.getInstance().addTab(taskModel.getShortTitle(), Icons.TASKEDIT, taskView);
+ MainView.getInstance().addTab(taskModel.getShortTitle(), Icons.TASK,
+ taskView);
int tabCount = MainView.getInstance().getTabCount();
taskView.setIndex(tabCount - 1);
MainView.getInstance().setSelectedIndex(tabCount - 1);
}
-
/**
- * Remove a task ID from the list of taskIDs in the model, update the
- * view to not have that task, and update the database to remove the task
- * from this bucket
+ * remove a task ID from the list of taskIDs in the model Sends an async
+ * update to the database
*
* @param rmid
* ID of the existing task to be removed
*/
public void removeTask(int rmid) {
model.removeTaskId(rmid);
-
- view.setModel(model);
- view.revalidate();
- view.repaint();
-
taskMap.remove(rmid);
updateInDatabase();
}
/**
- * Adds a task ID to the list of taskIDs in the bucket model. Sends an async
- * update to the database.
+ * Adds a task ID to the list of taskIDs in the bucket model. Sends an async update
+ * to the database.
*
* @param id
* ID of the existing task.
- * @param taskPresenter
+ * @param taskPresenter
* taskPresenter associated with the task
*/
public void addTask(int id, TaskPresenter taskPresenter) {
model.addTaskID(id);
if (!taskMap.containsKey(id)) {
- taskMap.put(id, taskPresenter);
+ taskMap.put(id, taskPresenter);
}
-
- if (taskPresenter.getBucket() != this) {
- taskPresenter.getBucket().removeTask(id);
- taskPresenter.setBucket(this);
- }
-
- taskPresenter.getModel().setStatus(this.getModel().getId());
- taskPresenter.updateView();
-
- /* Immediately add the view for instant feedback to the user */
- if (taskPresenter.getMiniView() != null) {
- this.view.addTaskToView(taskPresenter.getMiniView());
- }
-
- view.setModel(model);
- view.revalidate();
- view.repaint();
-
updateInDatabase();
}
@@ -336,14 +262,13 @@
*/
public void setModel(BucketModel model) {
this.model = model;
- this.writeModelToView();
+ writeModelToView();
}
/**
* Add the miniTaskView to view
- *
* @param miniView
- * The miniView associated with the task being added
+ * The miniView associated with the task being added
*/
public void addMiniTaskView(MiniTaskView miniView) {
view.addTaskToView(miniView);
@@ -359,40 +284,4 @@
public TaskPresenter getTask(int id) {
return taskMap.get(id);
}
-
- /**
- * removes all tasks from view and only adds back based on archive options
- */
- public void addMiniTaskstoView() {
- List<Integer> taskIds = model.getTaskIds();
- this.view.resetTaskList();
- for (int i : taskIds) {
- MiniTaskView miniTaskView = taskMap.get(i).getMiniView();
- if (MainView.getInstance().getShowArchived()) {
- view.addTaskToView(miniTaskView);
- } else {
- if (!taskMap.get(i).getModel().getIsArchived()) {
- view.addTaskToView(miniTaskView);
- }
- }
- }
- }
-
- /*
- * removes task from bucketView, presenter, and model
- *
- * @param task presenter of task to be moved
- */
-
- public void removeTaskView(TaskPresenter taskPresenter) {
- taskMap.remove(taskPresenter.getModel().getId());
- model.removeTaskId(taskPresenter.getModel().getId());
- view.removeTaskView(taskPresenter.getMiniView());
- Request request = Network.getInstance().makeRequest(
- "taskmanager/task/" + this.model.getId(), HttpMethod.DELETE);
- request.addObserver(new TaskObserver(taskPresenter));
- request.send();
- updateInDatabase();
-
- }
}
diff --git a/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/presenter/TaskObserver.java b/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/presenter/TaskObserver.java
index a289bf9..7611009 100644
--- a/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/presenter/TaskObserver.java
+++ b/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/presenter/TaskObserver.java
@@ -38,7 +38,7 @@
@Override
public void responseSuccess(IRequest iReq) {
System.out
- .println("Received response: " + iReq.getResponse().getBody());
+ .println("Received response: " + iReq.getResponse().getBody());
/*
* Take the appropriate action based on what the method of the request
@@ -51,9 +51,11 @@
case GET:
model = TaskModel.fromJsonArray(json)[0];
this.presenter.setModel(model);
+ this.presenter.updateView();
break;
case PUT:
+ System.out.println("Successfully saved new tasks!");
model = TaskModel.fromJson(json);
/*
* Set the new model and update the view to reflect the new data.
@@ -64,6 +66,7 @@
this.presenter.addHistory("Create");
this.presenter.setModel(model);
+ this.presenter.updateView();
/*
* Update the list of tasks in the bucket now that we know that it
diff --git a/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/presenter/TaskPresenter.java b/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/presenter/TaskPresenter.java
index 07ada79..3cd7606 100644
--- a/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/presenter/TaskPresenter.java
+++ b/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/presenter/TaskPresenter.java
@@ -12,27 +12,15 @@
import java.awt.Color;
import java.awt.Dialog;
import java.awt.Dimension;
-import java.awt.Point;
-import java.awt.datatransfer.DataFlavor;
-import java.awt.datatransfer.Transferable;
-import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
-import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
-import java.util.Date;
import java.util.List;
-import java.util.concurrent.TimeUnit;
-
-import javax.swing.JComponent;
-import javax.swing.SwingUtilities;
-import javax.swing.Timer;
-import javax.swing.TransferHandler;
import javax.swing.JComboBox;
@@ -40,11 +28,9 @@
import edu.wpi.cs.wpisuitetng.modules.core.models.User;
import edu.wpi.cs.wpisuitetng.modules.taskmanager.model.TaskModel;
import edu.wpi.cs.wpisuitetng.modules.taskmanager.view.ColorRenderer;
-import edu.wpi.cs.wpisuitetng.modules.taskmanager.view.GhostGlassPane;
import edu.wpi.cs.wpisuitetng.modules.taskmanager.view.Icons;
import edu.wpi.cs.wpisuitetng.modules.taskmanager.view.MainView;
import edu.wpi.cs.wpisuitetng.modules.taskmanager.view.MiniTaskView;
-import edu.wpi.cs.wpisuitetng.modules.taskmanager.view.ReturnToOrigin;
import edu.wpi.cs.wpisuitetng.modules.taskmanager.view.TaskView;
import edu.wpi.cs.wpisuitetng.modules.taskmanager.view.VerifyActionDialog;
import edu.wpi.cs.wpisuitetng.modules.taskmanager.view.ViewMode;
@@ -79,8 +65,6 @@
private BucketPresenter bucket;
private List<ActivityPresenter> activityPresenters;
-
- public final static DataFlavor TASK_DATA_FLAVOR = new DataFlavor(TaskPresenter.class, "Task");
/**
* Constructor for testing methods without creating View, or
@@ -115,11 +99,13 @@
assignedUserList = new ArrayList<Integer>(model.getAssignedTo());
this.view = new TaskView(model, viewMode, this);
this.miniView = new MiniTaskView(model);
- this.miniView.setCollapsedView();
final Request request = Network.getInstance().makeRequest("core/user",
HttpMethod.GET);
request.addObserver(new UsersObserver(this));
request.send();
+ Dimension maxView = new Dimension(bucket.getView().getWidth()-32, bucket.getView().getHeight());
+ this.miniView.setMaximumSize(maxView);//prevent horizontal scroll
+ this.miniView.getTaskNameLabel().setMaximumSize(maxView);
this.activityPresenters = new ArrayList<ActivityPresenter>();
registerCallbacks();
@@ -128,120 +114,27 @@
/**
* Register callbacks with the local view.
*/
- /**
- *
- */
private void registerCallbacks() {
- // onclick listener to expand minitaskview when clicked
- miniView.addOnClickOpenExpandedView(new MouseAdapter() {
+ // onclick listener to open new tabs when minitaskview is clicked
+ miniView.addOnClickOpenTabView(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
- miniView.setModel(model);
- if(!miniView.isExpanded()){
- addUsersToMiniTaskView();
- miniView.setExpandedView();
- } else {
- miniView.setCollapsedView();
- }
- view.getCommentView().toggleTextField(ViewMode.EDITING);
- bucket.getView().revalidate();
- bucket.getView().repaint();
- }
- });
-
- // on click listener to edit tasks from the expanded task view
- miniView.addOnClickEditButton(new ActionListener(){
- @Override
- public void actionPerformed(ActionEvent e) {
MainView.getInstance().addTab(model.getShortTitle(),
- Icons.TASKEDIT, view);// this line chooses tab title
- if(model.getIsArchived()){
- view.setViewMode(ViewMode.ARCHIVING);
- view.getCommentView().toggleTextField(ViewMode.ARCHIVING);
- view.disableEdits();
- }
- else{
- view.setViewMode(ViewMode.EDITING);
- view.enableEdits();
- }
+ Icons.TASK, view);// this line chooses tab title
+ view.setViewMode(ViewMode.EDITING);
+ view.getCommentView().toggleTextField(ViewMode.EDITING);
viewMode = view.getViewMode();
int tabCount = MainView.getInstance().getTabCount();
view.setIndex(tabCount - 1);
MainView.getInstance().setSelectedIndex(tabCount - 1);
MainView.getInstance().setToolTipTextAt(tabCount - 1,
model.getTitle());
- miniView.setModel(model);
- miniView.setCollapsedView();
- }
- });
-
- /* Set a handler to move the task when it's dragged and dropped */
- miniView.setTransferHandler(new TransferHandler() {
- /**
- * @return {@link TransferHandler#MOVE}. At least for now, tasks
- * are moved, never copied or linked.
- */
- @Override
- public int getSourceActions(JComponent c) {
- return MOVE;
- }
-
- /**
- * @return false always, since things can't be dragged onto tasks
- */
- @Override
- public boolean canImport(TransferSupport support) {
- return false;
- }
-
- /**
- * @return A transferable for the task presenter
- */
- @Override
- protected Transferable createTransferable(JComponent c) {
- return new Transferable() {
- @Override
- public DataFlavor[] getTransferDataFlavors() {
- return new DataFlavor[] { TASK_DATA_FLAVOR };
- }
- @Override
- public boolean isDataFlavorSupported(DataFlavor flavor) {
- return flavor == TASK_DATA_FLAVOR;
- }
-
- @Override
- public Object getTransferData(DataFlavor flavor)
- throws UnsupportedFlavorException, IOException {
- return TaskPresenter.this;
- }
- };
- }
-
- /**
- * Hide the ghosted image after the drag and drop is done
- */
- protected void exportDone(JComponent source, Transferable data, int action) {
- GhostGlassPane glassPane = MainView.getInstance().getGlassPane();
- if(action != NONE) {
- glassPane.setVisible(false);
- miniView.setColorHighlighted(false);
- } else {
- Point end = new Point(source.getLocationOnScreen());
- SwingUtilities.convertPointFromScreen(end, glassPane);
-
- end.x += glassPane.getStartDragPoint().x;
- end.y += glassPane.getStartDragPoint().y;
-
- Timer backTimer = new Timer(1000 / 60, new ReturnToOrigin(glassPane, glassPane.getPoint(), end));
- backTimer.start();
- miniView.setColorHighlighted(false);
- }
}
});
/**
- * Add listeners to the taskView okButton
+ * Open the task tab when a task is clicked
*
* @param ActionListener
*/
@@ -256,37 +149,37 @@
view.setViewMode(ViewMode.EDITING);
MainView.getInstance().remove(index);
MainView.getInstance().setSelectedIndex(0);
-
}
else {
- if(viewMode == ViewMode.ARCHIVING){
- int newIndex = MainView.getInstance().indexOfComponent(view);
- MainView.getInstance().remove(newIndex);
- model.setIsArchived(false);
+ updateBeforeModel();
+ //check if the task is switching buckets
+ if (view.getStatus() != bucket.getModel().getId()) {
+ MainView.getInstance()
+ .getWorkflowPresenter()
+ .moveTask(model.getId(), view.getStatus(),
+ bucket.getModel().getId());
+
+ //order of methods matter here.
+ saveView();
+ switchBucketUpdateViews();
+ MainView.getInstance().setTitleAt(index,
+ model.getShortTitle());
+ MainView.getInstance().setToolTipTextAt(index, model.getTitle());
+ addHistory(beforeModel, model);
+ view.getCommentView().revalidate();
+ view.getCommentView().repaint();
+
+ } else { // not switching buckets
saveView();
updateView();
- view.enableEdits();
-
+ MainView.getInstance().setTitleAt(index,
+ model.getShortTitle());
+ MainView.getInstance().setToolTipTextAt(index, model.getTitle());
+ addHistory(beforeModel, model);
}
- else{
-
- }
- updateBeforeModel();
- saveView();
- updateView();
- MainView.getInstance().setTitleAt(index,
- model.getShortTitle());
- MainView.getInstance().setToolTipTextAt(index, model.getTitle());
- addHistory(beforeModel, model);
}
- MainView.getInstance().resetAllBuckets();
-
- miniView.setModel(model);
- miniView.revalidate();
- miniView.repaint();
-
}
});
@@ -361,12 +254,7 @@
@Override
public void actionPerformed(ActionEvent e) {
deleteDialog.setModalityType(Dialog.ModalityType.APPLICATION_MODAL);
- if(viewMode == ViewMode.ARCHIVING){
- deleteDialog.setCommentLabelText("Are you sure you want to delete this task?");
- }
- else{
- deleteDialog.setCommentLabelText("Are you sure you want to archive this task?");
- }
+ deleteDialog.setCommentLabelText("Are you sure you want to delete this task?");
deleteDialog.addConfirmButtonListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
@@ -382,22 +270,10 @@
}
});
deleteDialog.setVisible(true);
- if(deleteDialogConfirmed) {//delete has been confirmed
+ if(deleteDialogConfirmed) {
int index = MainView.getInstance().indexOfComponent(view);
MainView.getInstance().remove(index);
- if(viewMode == ViewMode.ARCHIVING){//delete task
-
- TaskPresenter taskPresenter = bucket.getTask(model.getId());
- bucket.removeTaskView(taskPresenter);
-
- }
- else{
- model.setIsArchived(true);
- saveView();
- updateView();
- view.disableEdits();
- MainView.getInstance().resetAllBuckets();
- }
+ MainView.getInstance().getWorkflowPresenter().archiveTask(model.getId(), bucket.getModel().getId());
}
}
});
@@ -557,7 +433,7 @@
+ dateFormat.format(cal.getTime()) + "]: ";
ActivityPresenter activityPresenter = new ActivityPresenter(this,
userInformation
- + view.getCommentView().getCommentText().getText(),
+ + view.getCommentView().getCommentText().getText(),
false);
view.getCommentView().postActivity(activityPresenter.getView());
@@ -662,7 +538,7 @@
public void addUsersToAllUserList(User[] users) {
this.allUserArray = users;
}
-
+
/**
* Takes the allUsers array, and checks users with assigned users list
* all assigned users get added to the assigned view, and all others
@@ -700,31 +576,22 @@
model.setDescription(view.getDescriptionText());
model.setDueDate(view.getDueDate());
model.setAssignedTo(assignedUserList);
+ model.setStatus(view.getStatus());
model.setLabelColor(view.getLabelColor());
+ this.bucket = MainView.getInstance().getWorkflowPresenter()
+ .getBucket(view.getStatus());
}
/**
* Update the view with data from the model
*/
public void updateView() {
+ view.setStatus(model.getStatus());
view.setModel(model);
miniView.setModel(model);
updateCommentView();
assignedUserList = new ArrayList<Integer>(model.getAssignedTo());
addUsersToView();
- this.setIconForMinitaskView();
-
- if(model.getIsArchived()) {
- miniView.setColorArchived(true);
- }
- else {
- miniView.setColorArchived(false);
- }
- view.revalidate();
- view.repaint();
-
- miniView.setModel(model);
- miniView.setToolTipText(model.getTitle());
miniView.updateLabel();
}
@@ -735,6 +602,7 @@
* Function only used when a task is switching buckets.
*/
private void switchBucketUpdateViews() {
+ view.setStatus(model.getStatus());
view.setModel(model);
miniView.setModel(model);
assignedUserList = new ArrayList<Integer>(model.getAssignedTo());
@@ -781,7 +649,7 @@
* @return the TaskView for the current TaskPresenter
*/
public TaskView getView() {
- return this.view;
+ return view;
}
/**
@@ -790,7 +658,7 @@
* @return miniView for Task
*/
public MiniTaskView getMiniView() {
- return this.miniView;
+ return miniView;
}
/**
@@ -799,7 +667,7 @@
* @return This provider's model.
*/
public TaskModel getModel() {
- return this.model;
+ return model;
}
/**
@@ -816,7 +684,6 @@
p.load();
activityPresenters.add(p);
}
- this.updateView();
}
/**
@@ -828,14 +695,6 @@
}
/**
- * @param bucket the bucket that this task is in
- */
- public void setBucket(BucketPresenter bucket) {
- this.bucket = bucket;
- this.model.setStatus(bucket.getModel().getId());
- }
-
- /**
* Removes a user from the assignedTo list
* @param user User to remove from assignedTo
*/
@@ -851,14 +710,14 @@
this.assignedUserList.add(user.getIdNum());
this.view.validateFields();
}
-
+
/**
- * @return assigned users list
+ * @return A shallow copy of the temporary assigned users list, not the model's user list
*/
public List<Integer> getAssignedUserList() {
return this.assignedUserList;
}
-
+
/**
* @param enable Whether or not to enable the cancel dialog
*/
@@ -866,7 +725,6 @@
this.allowCancelDialog = enable;
this.cancelDialogConfirmed = !enable; // if the dialog is enabled, the confirmation of the dialog box is opposite
}
-
/**
* returns the Username with the given ID, otherwise blank.
*
@@ -880,48 +738,5 @@
return u.getUsername();
}
return "";
-}
-
- /**
- * set icon for the task in update view
- */
- public void setIconForMinitaskView(){
- Calendar cal = Calendar.getInstance();
- Date nowDate = cal.getTime(); //Current Date
- Date dueDate = model.getDueDate();
- //Get time differences
- long leftTime = dueDate.getTime() - nowDate.getTime();
- long leftInHours = TimeUnit.MILLISECONDS.toHours(leftTime);
- // Set icons
- if(leftInHours == 0) { //On the date it's due
- this.miniView.setTaskNameLabelIcon(Icons.TASKDUE);
- }
- else {
- if (leftInHours < -24){ //Overdue
- this.miniView.setTaskNameLabelIcon(Icons.TASKDUE);
- }
- else if (leftInHours < 0){ //Nearly due
- this.miniView.setTaskNameLabelIcon(Icons.TASKNEARDUE);
- }
- else if (leftInHours < 48){ //In progress
- this.miniView.setTaskNameLabelIcon(Icons.TASKSTART);
- }
- else { //New
- this.miniView.setTaskNameLabelIcon(Icons.TASKNEW);
- }
- }
- }
-
- /**
- * Wrapper function to add all assigned users to the miniTaskView
- */
- public void addUsersToMiniTaskView(){
- List<String> userNames = new ArrayList<String>();
- for(User user: allUserArray){
- if(assignedUserList.contains(user.getIdNum())){
- userNames.add(user.getName());
- }
- }
- miniView.addUsersToUserPanel(userNames);
}
}
diff --git a/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/presenter/WorkflowPresenter.java b/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/presenter/WorkflowPresenter.java
index 0219511..08aef0c 100644
--- a/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/presenter/WorkflowPresenter.java
+++ b/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/presenter/WorkflowPresenter.java
@@ -200,6 +200,18 @@
}
/**
+ * moves a task from a bucket to the archive
+ *
+ * @param taskId
+ * id of the task being moved
+ * @param bucketId
+ * id of the bucket the task is being removed from
+ */
+ public void archiveTask(int taskId, int bucketId) {
+ moveTask(taskId, 5, bucketId);
+ }
+
+ /**
* get the bucket id from the hashmap
* @param id the id of the bucket to be retrieved
* @return the bucket model from the hashmap
diff --git a/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/BucketView.java b/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/BucketView.java
index 0d67634..994095d 100644
--- a/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/BucketView.java
+++ b/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/BucketView.java
@@ -12,7 +12,6 @@
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
-import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;
@@ -54,8 +53,9 @@
this.setMinimumSize(new Dimension(300, 200));
this.setBackground(Color.LIGHT_GRAY);
this.setBorder(new EmptyBorder(0, 5, 5, 5));
- this.setLayout(new MigLayout("", "[grow]", "[grow]"));
+ this.setLayout(new MigLayout("fill"));
this.titleLabel.setFont(new Font("Tahoma", Font.BOLD, 14));
+
// Start by adding the changeable title to the top of the view
this.add(titlePanel, "dock north");
this.titlePanel.setBackground(Color.LIGHT_GRAY);
@@ -63,8 +63,8 @@
this.titlePanel.setLayout(new MigLayout("", "[grow]", "[grow]"));
this.titlePanel.add(titleLabel, "cell 0 0, alignx center, aligny center");
taskScrollPane.setBorder(null);
-
-
+
+
// Need a scroll pane to allow us to scroll through all tasks in the bucketView.
this.add(taskScrollPane, "dock north");
taskViewHolderPanel.setBorder(null);
@@ -74,7 +74,7 @@
this.setModel(model);
}
-
+
/**
* @return Returns a list of TaskViews
*/
@@ -90,7 +90,7 @@
this.titleLabel.setText(this.model.getTitle());
}
-
+
/**
* Adds a single MiniTaskView to the bucket, with spacers
* @param task The MiniTaskView to be added to the bucket
@@ -98,27 +98,7 @@
public void addTaskToView(MiniTaskView task){
this.taskViews.add(task);
this.taskViewHolderPanel.add(task, "dock north");
-
- Dimension maxView = new Dimension((int) this.getPreferredSize().getWidth()-32, (int) this.getMaximumSize().getHeight());
- task.setMaximumSize(maxView);//prevent horizontal scroll
- task.getTaskNameLabel().setMaximumSize(maxView);
+ Component spacerStrut = Box.createVerticalStrut(5);
+ this.taskViewHolderPanel.add(spacerStrut, "dock north");
}
-
-
- /**
- * resets the task list by removing all from view
- */
- public void resetTaskList(){
- this.taskViewHolderPanel.removeAll();
- }
-
-
-/**
- * Removes miniTaskView from BucketView
- * @param miniTaskView miniTaskView to be removed
- */
-public void removeTaskView(MiniTaskView miniTaskView){
- this.taskViews.remove(miniTaskView);
- }
-
}
diff --git a/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/CommentView.java b/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/CommentView.java
index 58e8026..b4348c3 100644
--- a/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/CommentView.java
+++ b/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/CommentView.java
@@ -80,7 +80,6 @@
this.clearCommentButton.setIcon(Icons.CLEAR);
this.setupListeners();
}
-
/**
* If the current ViewMode is CREATING,
* then we disable the post and clear comment buttons, and replace the background text for JTextBox.
@@ -96,13 +95,6 @@
this.postCommentButton.setEnabled(false);
this.clearCommentButton.setEnabled(false);
}
- else if(currentView.equals(ViewMode.ARCHIVING)){
- this.commentText.setEditable(false);
- this.commentText.setPrompt("Comments unavailable because task is Archived.");
- this.commentText.setPromptForeground(Color.GRAY);
- this.postCommentButton.setEnabled(false);
- this.clearCommentButton.setEnabled(false);
- }
else{
this.commentText.setEditable(true);
this.commentText.setPrompt("Write a comment...");
diff --git a/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/GhostGlassPane.java b/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/GhostGlassPane.java
deleted file mode 100644
index e2221cc..0000000
--- a/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/GhostGlassPane.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 -- WPI Suite
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- ******************************************************************************/
-
-package edu.wpi.cs.wpisuitetng.modules.taskmanager.view;
-
-import java.awt.AlphaComposite;
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.Graphics;
-import java.awt.Graphics2D;
-import java.awt.Image;
-import java.awt.Point;
-import java.awt.RenderingHints;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import java.awt.geom.AffineTransform;
-import java.awt.image.BufferedImage;
-
-import javax.swing.JComponent;
-import javax.swing.JPanel;
-
-/**
- * Draws a transparent version of something that's being dragged and dropped
- */
-public class GhostGlassPane extends JPanel {
-
- private AlphaComposite composite;
- private BufferedImage image;
- private Point point, startDrag;
-
- private final static double MAX_ROTATION = 8 * Math.PI / 180;
- private double rotation;
-
- /**
- * Construct the glass pane
- */
- public GhostGlassPane() {
- this.composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER,
- 0.5f);
- this.point = null;
-
- /*
- * Make this panel transparent so we can render it over the rest of the
- * stuff
- */
- this.setOpaque(false);
- }
-
- /**
- * @param component
- * The component to draw under the cursor
- * @param startDrag
- * The initial position of the cursor, relative to the component
- */
- public void setGhostComponent(Component c, Point startDrag) {
- this.image = new BufferedImage(c.getWidth() + 2, c.getHeight() + 2,
- BufferedImage.TYPE_INT_ARGB);
-
- Graphics2D g2d = (Graphics2D) this.image.getGraphics();
- g2d.translate(1.0, 1.0);
- c.paint(g2d);
-
- rotation = 0.0;
-
- this.startDrag = startDrag;
- }
-
- /**
- * @param point
- * The location of the cursor
- */
- public void setPoint(Point point) {
- this.point = point;
- }
-
- /**
- * @return The location of the cursor
- */
- public Point getPoint() {
- return this.point;
- }
-
- /**
- * @return The position of where the cursor started dragging
- */
- public Point getStartDragPoint() {
- return this.startDrag;
- }
-
- @Override
- public void paintComponent(Graphics g) {
- if (isVisible()) {
- Graphics2D g2d = (Graphics2D) g;
-
- if (this.image != null && this.point != null) {
- g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
- RenderingHints.VALUE_INTERPOLATION_BICUBIC);
- g2d.rotate(rotation, this.point.x, this.point.y);
- g2d.setComposite(this.composite);
- g2d.drawImage(this.image, this.point.x - this.startDrag.x,
- this.point.y - this.startDrag.y, null);
-
- /* Gradually approach the maximum rotation as the user drags */
- if (rotation < MAX_ROTATION)
- rotation += MAX_ROTATION / 10.0;
- }
- }
- }
-
- @Override
- public void setVisible(boolean visible) {
- super.setVisible(visible);
-
- /* Don't save the position of the ghost object between drags */
- if (!visible) {
- this.point = null;
- }
- }
-}
diff --git a/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/Icons.java b/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/Icons.java
index 79cc538..96bf0c1 100644
--- a/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/Icons.java
+++ b/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/Icons.java
@@ -28,18 +28,10 @@
public final static Icon CREATE_TASK = new ImageIcon(Icons.class.getResource("create-task.png"));
public final static Icon ERROR = new ImageIcon(Icons.class.getResource("error.png"));
public final static Icon ERROR_LARGE = new ImageIcon(Icons.class.getResource("error-large.png"));
- public final static Icon HIDE_ARCHIVE_LARGE = new ImageIcon(Icons.class.getResource("hide-archive-large.png"));
public final static Icon HISTORY = new ImageIcon(Icons.class.getResource("history.png"));
public final static Icon OK = new ImageIcon(Icons.class.getResource("okay.png"));
public final static Icon REMOVE_USER = new ImageIcon(Icons.class.getResource("remove-user.png"));
- public final static Icon SHOW_ARCHIVE_LARGE = new ImageIcon(Icons.class.getResource("show-archive-large.png"));
public final static Icon TASK = new ImageIcon(Icons.class.getResource("task.png"));
public final static Icon TRASH = new ImageIcon(Icons.class.getResource("trash.png"));
public final static Icon WORKFLOW = new ImageIcon(Icons.class.getResource("workflow.png"));
-
- public final static Icon TASKNEW = new ImageIcon(Icons.class.getResource("task-normal.png"));
- public final static Icon TASKSTART = new ImageIcon(Icons.class.getResource("task-due-soon.png"));
- public final static Icon TASKNEARDUE = new ImageIcon(Icons.class.getResource("task-due-very-soon.png"));
- public final static Icon TASKDUE = new ImageIcon(Icons.class.getResource("task-overdue.png"));
- public final static Icon TASKEDIT = new ImageIcon(Icons.class.getResource("task-edit.png"));
}
diff --git a/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/MainView.java b/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/MainView.java
index e44b5c6..60a4e37 100644
--- a/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/MainView.java
+++ b/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/MainView.java
@@ -11,7 +11,6 @@
import java.beans.PropertyChangeEvent;
import java.io.IOException;
-import java.util.Map;
import javax.imageio.ImageIO;
import javax.swing.Icon;
@@ -21,7 +20,6 @@
import javax.swing.JTabbedPane;
import net.miginfocom.swing.MigLayout;
-import edu.wpi.cs.wpisuitetng.modules.taskmanager.presenter.BucketPresenter;
import edu.wpi.cs.wpisuitetng.modules.taskmanager.presenter.WorkflowPresenter;
/**
@@ -32,9 +30,8 @@
private static final long serialVersionUID = -346061317795260862L;
private JScrollPane workflowScrollPane = new JScrollPane();
private WorkflowPresenter workflowPresenter = new WorkflowPresenter(0);
- private GhostGlassPane glassPane = new GhostGlassPane();
private static final MainView mainView = new MainView();
- private boolean showArchived = true;
+
private MainView() {
this.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
this.addTab("Workflow", Icons.WORKFLOW, workflowScrollPane);
@@ -46,22 +43,6 @@
this.workflowPresenter.load();
});
}
-
- /**
- * Sets the glass pane when the main view is added to the window
- */
- public void addNotify() {
- super.addNotify();
-
- this.getRootPane().setGlassPane(this.glassPane);
- }
-
- /**
- * @return The glass pane for this component
- */
- public GhostGlassPane getGlassPane() {
- return this.glassPane;
- }
public static MainView getInstance() {
return mainView;
@@ -90,29 +71,4 @@
this.workflowPresenter = workflowPresenter;
this.workflowScrollPane.setViewportView(workflowPresenter.getView());
}
-
-
- /** indicates if archived tasks are shown
- * @return if archived tasks are shown
- */
- public boolean getShowArchived() {
- return showArchived;
- }
-
- /**set if archived tasks are shown
- * @param showArchived indicates if archived tasks are shown
- */
- public void setShowArchived(boolean showArchived) {
- this.showArchived = showArchived;
- }
-
- /**
- * resets and reloads all buckets
- */
- public void resetAllBuckets(){
- for(Map.Entry<Integer, BucketPresenter> bucketEntry: getWorkflowPresenter().getBucketPresenters().entrySet()){
- BucketPresenter bucket = bucketEntry.getValue();
- bucket.addMiniTaskstoView();
- }
- }
}
\ No newline at end of file
diff --git a/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/MiniTaskView.java b/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/MiniTaskView.java
index ae705f1..79ba641 100644
--- a/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/MiniTaskView.java
+++ b/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/MiniTaskView.java
@@ -11,37 +11,16 @@
import java.awt.Color;
import java.awt.Dimension;
-import java.awt.Component;
-import java.awt.Point;
-import java.awt.dnd.DragSource;
-import java.awt.dnd.DragSourceAdapter;
-import java.awt.dnd.DragSourceDragEvent;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
-import java.awt.event.ActionListener;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.List;
+import java.util.Date;
-
-import javax.swing.Icon;
-import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
-import javax.swing.SwingUtilities;
import javax.swing.TransferHandler;
-import javax.swing.UIManager;
import net.miginfocom.swing.MigLayout;
-import javax.swing.JScrollPane;
-import javax.swing.ScrollPaneConstants;
-import javax.swing.border.Border;
-import javax.swing.border.CompoundBorder;
import javax.swing.border.EmptyBorder;
-import javax.swing.border.LineBorder;
-import javax.swing.border.TitledBorder;
import edu.wpi.cs.wpisuitetng.modules.taskmanager.model.TaskModel;
@@ -51,180 +30,56 @@
*/
public class MiniTaskView extends JPanel {
- private JPanel colorPanel = new JPanel();
- private static final long serialVersionUID = -5428820718299212324L;
- private JLabel taskNameLabel = new JLabel();
- private JButton editButton = new JButton("Edit");
- private JPanel userPanel = new JPanel();
- private JLabel dueDateLabel = new JLabel();
- private JPanel holderPanel = new JPanel();
- private boolean expanded = false;
- private final JScrollPane userScrollPane = new JScrollPane();
private TaskModel model;
+ private JPanel colorLabel;
+
+ JLabel taskNameLabel = new JLabel();
/**
- * Create the panel. Initially in collapsed view.
- * @param model The model to render in this view
+ * @return Label of taskName
+ */
+ public JLabel getTaskNameLabel() {
+ return taskNameLabel;
+ }
+
+ /**
+ * Create the panel.
+ *
+ * @param model
+ * The model to render in this view
*/
public MiniTaskView(TaskModel model) {
setLayout(new MigLayout("", "[grow][30px]", "[grow]"));
- this.holderPanel.setLayout(new MigLayout("fill"));
- this.holderPanel.setMinimumSize(new Dimension(50,10));
- this.colorPanel.setMinimumSize(new Dimension(10,15));
- this.holderPanel.add(colorPanel, "dock north");
taskNameLabel.setBorder(new EmptyBorder(8, 8, 8, 8));
- this.taskNameLabel.setIcon(Icons.TASKNEW);
- this.setBorder(new CompoundBorder(new LineBorder(Color.LIGHT_GRAY, 1), new EmptyBorder(0, 8, 0, 8)));
- this.setExpandedView();
+ this.add(taskNameLabel, "cell 0 0");
+ this.taskNameLabel.setIcon(Icons.TASK);
+
this.setModel(model);
- /* Initialize a drag when the user clicks on the MiniTaskView */
- MouseAdapter dragAdapter = new MouseAdapter() {
- @Override
- public void mouseDragged(MouseEvent e) {
- if (MiniTaskView.this.model.getIsArchived()) {
- /* Archived tasks cannot be dragged */
- return;
- }
-
- TransferHandler handler = getTransferHandler();
- handler.exportAsDrag(MiniTaskView.this, e, TransferHandler.MOVE);
-
- /* Set a ghost version of this view to show under the cursor as
- * it gets dragged.
- */
- GhostGlassPane glassPane = (GhostGlassPane) getRootPane().getGlassPane();
- glassPane.setGhostComponent(MiniTaskView.this, e.getPoint());
- glassPane.setVisible(true);
-
- /* Highlight the MiniTaskView to show which task is being dragged */
- setColorHighlighted(true);
- }
- };
-
- DragSource.getDefaultDragSource().addDragSourceMotionListener(new DragSourceAdapter() {
- @Override
- public void dragMouseMoved(DragSourceDragEvent dsde) {
- /* Move the ghost image when the mouse is moved during a drag */
- GhostGlassPane glassPane = MainView.getInstance().getGlassPane();
- Point point = dsde.getLocation();
- SwingUtilities.convertPointFromScreen(point, glassPane);
- glassPane.setPoint(point);
- glassPane.repaint();
- }
- });
- this.addMouseMotionListener(dragAdapter);
- this.taskNameLabel.addMouseMotionListener(dragAdapter);
+ this.setTransferHandler(new TransferHandler("model"));
- this.userPanel.setLayout(new MigLayout("fill"));
- this.userScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
- this.userScrollPane.setBorder(new TitledBorder(null, "Assigned Users", TitledBorder.LEADING, TitledBorder.TOP, null, null));
- this.userScrollPane.setViewportView(userPanel);
- this.setColorHighlighted(false);
- }
+ JPanel holderPanel = new JPanel();
+ holderPanel.setBorder(null);
+ add(holderPanel, "cell 1 0,grow");
+ holderPanel.setLayout(new MigLayout("fill"));
- /**
- * @param If <code>true</code>, this view will be rendered with a different
- * color scheme to suggest that it's selected. This is used to indicate
- * that a task is being dragged and dropped.
- */
- public void setColorHighlighted(boolean highlighted) {
- Color foreground, background;
-
- if (highlighted) {
- background = UIManager.getColor("textHighlight");
- } else {
- background = UIManager.getColor("menu");
- }
-
- this.setBackground(background);
- this.userPanel.setBackground(background);
- this.userScrollPane.setBackground(background);
- }
+ colorLabel = new JPanel();
+ holderPanel.add(colorLabel, "dock north");
+ colorLabel.setMaximumSize(new Dimension(30, 10));
- /**
- * @param archived If <code>true</code>, set the colors of the view to
- * reflect that the task is archived
- */
- public void setColorArchived(boolean archived) {
- Color foreground, background;
-
- if (archived) {
- background = new Color(210, 210, 210);
- } else {
- background = UIManager.getColor("menu");
- }
-
- this.setBackground(background);
- this.userPanel.setBackground(background);
- this.userScrollPane.setBackground(background);
- }
-
- /**
- * Remove all of the components in the view, then add them back in
- * with the proper layout for a collapsed view.
- */
- public void setCollapsedView(){
- this.removeAll();
- this.setLayout(new MigLayout("", "[grow][]", "-5[grow]"));
- this.add(taskNameLabel, "cell 0 0,grow");
- this.add(holderPanel, "cell 1 0,grow");
- this.holderPanel.setBorder(null);
- this.expanded = false;
- this.revalidate();
- this.repaint();
- }
-
-
- /**
- * Remove all of the components in the view, then add them back in
- * with the proper layout for an expanded view.
- */
- public void setExpandedView(){
- this.removeAll();
-
- this.setLayout(new MigLayout("", "0[grow][grow][]", "0[][][][]"));
- this.add(taskNameLabel, "cell 0 0 2 1");
- this.add(dueDateLabel, "cell 0 1");
- this.add(userScrollPane, "cell 0 2 3 1,grow");
- this.add(holderPanel, "cell 2 0,grow");
- this.expanded = true;
- this.add(editButton, "cell 0 3,alignx left,aligny bottom");
- this.revalidate();
- this.repaint();
- }
-
- /**
- * Adds all users in the UserList to the panel as text.
- * @param userList List of user names to add to the panel.
- */
- public void addUsersToUserPanel(List<String> userList){
- this.userPanel.removeAll();
- for(String name: userList){
- JLabel userLabel = new JLabel(name);
- this.userPanel.add(userLabel, "dock north");
- }
}
/**
* Add the listener for changing tabs
- * @param listener the event that will trigger the action
- */
- public void addOnClickOpenExpandedView(MouseListener listener){
+ *
+ * @param listener
+ * the event that will trigger the action
+ */
+ public void addOnClickOpenTabView(MouseListener listener) {
this.addMouseListener(listener);
this.taskNameLabel.addMouseListener(listener);
- this.userPanel.addMouseListener(listener);
- this.userScrollPane.addMouseListener(listener);
}
-
- /**
- * Adds the listener for opening the editing tab of the task.
- * @param listener The listener that reacts on button click.
- */
- public void addOnClickEditButton(ActionListener listener){
- this.editButton.addActionListener(listener);
- }
-
+
/**
* updates this miniTaskView's color label with the color from this MiniTaskView's Model.
* paints null if the user selected no label.
@@ -232,9 +87,9 @@
public void updateLabel() {
if (model.getLabelColor() != null) {
if (!model.getLabelColor().equals(new Color(255, 255, 255)))
- colorPanel.setBackground(model.getLabelColor());
+ colorLabel.setBackground(model.getLabelColor());
else
- colorPanel.setBackground(null);
+ colorLabel.setBackground(null);
}
}
@@ -243,56 +98,22 @@
* The model to render in this view
*/
public void setModel(TaskModel model) {
- DateFormat dateFormat = new SimpleDateFormat("EEE MMM dd, yyyy");
this.model = model;
- if (this.model.getIsArchived()) {
- this.taskNameLabel.setText(this.model.getTitle() + " (archived)");
- } else {
- this.taskNameLabel.setText(this.model.getTitle());
- }
+ this.taskNameLabel.setText(this.model.getTitle());
this.taskNameLabel.setToolTipText(this.model.getTitle());
-
- if(this.model.getDueDate() != null){
- this.dueDateLabel.setText("Due : " + dateFormat.format(this.model.getDueDate()));
- }
- this.revalidate();
- this.repaint();
}
/**
- * @return If this task is expanded or not.
- */
- public boolean isExpanded(){
- return expanded;
- }
-
- /**
* @return The model that this view renders
*/
public TaskModel getModel() {
return this.model;
}
-
/**
* @return the panel to be filled with color
*/
public JPanel getColorLabel() {
- return colorPanel;
- }
-
- /**
- * Set Icon for this miniTaskView
- * @param icon
- */
- public void setTaskNameLabelIcon(Icon icon) {
- this.taskNameLabel.setIcon(icon);
- }
-
- /*
- * @return the label containing the task name within this view
- */
- public JLabel getTaskNameLabel() {
- return this.taskNameLabel;
+ return colorLabel;
}
}
diff --git a/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/ReturnToOrigin.java b/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/ReturnToOrigin.java
deleted file mode 100644
index 9f1c8f8..0000000
--- a/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/ReturnToOrigin.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 -- WPI Suite
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- ******************************************************************************/
-
-package edu.wpi.cs.wpisuitetng.modules.taskmanager.view;
-
-import java.awt.Point;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-
-import javax.swing.SwingUtilities;
-import javax.swing.Timer;
-
-/**
- * This class returns the GhostPane back its original location
- * Adapted Code from Romain Guy
- */
-public class ReturnToOrigin implements ActionListener {
- private boolean isInit;
- private long start;
-
- private Point startPoint;
- private Point endPoint;
- private GhostGlassPane glassPane;
-
- private static final double INIT_SPEED = 1000.0;
- private static final double INIT_ACC = 6000.0;
-
- /**
- * Constructs the fields for the returning glasspane
- *
- * @param glassPane
- * The dragged item being returned
- * @param start
- * The point where the item is dropped
- * @param end
- * The point where the item will end up returning to
- */
- public ReturnToOrigin(GhostGlassPane glassPane, Point start, Point end) {
- this.glassPane = glassPane;
- this.startPoint = start;
- this.endPoint = end;
- isInit = false;
- }
-
- /**
- * Starts the "animation" of the glasspane returning to the original
- * location. It will constantly recalculate the position of the item and
- * repaint it.
- */
- public void actionPerformed(ActionEvent e) {
- if (!isInit) {
- isInit = true;
- start = System.currentTimeMillis();
- }
-
- long elapsed = System.currentTimeMillis() - start;
- double time = (double) elapsed / 1000.0;
-
- /* slope */
- double a = (endPoint.y - startPoint.y)
- / (double) (endPoint.x - startPoint.x);
- /* y = mx + b */
- double b = endPoint.y - a * endPoint.x;
-
- /* Animation travel speed: 1/2*at^2 + vt, for the x direction */
- int travelX = (int) (INIT_ACC * time * time / 2.0 + INIT_SPEED * time);
-
- /* If the dragged is in the other direction switch directions */
- if (startPoint.x > endPoint.x) {
- travelX = -travelX;
- }
-
- /* Animation travel speed for the y direction */
- int travelY = (int) ((startPoint.x + travelX) * a + b);
- /* Distance remaining from the original location */
- int distanceX = (int) Math.abs(startPoint.x - endPoint.x);
-
- if (Math.abs(travelX) >= distanceX) {
- ((Timer) e.getSource()).stop();
-
- glassPane.setPoint(endPoint);
- glassPane.repaint();
-
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- glassPane.setVisible(false);
- }
- });
- return;
- }
-
- glassPane.setPoint(new Point(startPoint.x + travelX, travelY));
- glassPane.repaint();
- }
-}
diff --git a/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/TaskButtonsPanel.java b/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/TaskButtonsPanel.java
index f106c8d..ae6019a 100644
--- a/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/TaskButtonsPanel.java
+++ b/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/TaskButtonsPanel.java
@@ -82,7 +82,7 @@
okString = "Update";
clearString = "Undo Changes";
cancelString = "Close";
- deleteString = "Archive";
+ deleteString = "Delete";
this.okButton.setVisible(true);
this.clearButton.setVisible(true);
this.cancelButton.setVisible(true);
@@ -90,12 +90,11 @@
} else if (viewMode == ViewMode.ARCHIVING) {
okString = "Restore";
clearString = "";
- cancelString = "Close";
+ cancelString = "";
deleteString = "Delete";
this.okButton.setVisible(true);
- this.okButton.setEnabled(true);
this.clearButton.setVisible(false);
- this.cancelButton.setVisible(true);
+ this.cancelButton.setVisible(false);
this.deleteButton.setVisible(true);
}
this.okButton.setText(okString);
diff --git a/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/TaskView.java b/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/TaskView.java
index 58c153f..98c34e4 100644
--- a/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/TaskView.java
+++ b/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/TaskView.java
@@ -11,12 +11,12 @@
package edu.wpi.cs.wpisuitetng.modules.taskmanager.view;
import java.awt.Color;
-import java.awt.Component;
import java.awt.event.ActionListener;
import java.awt.event.ItemListener;
import java.text.ParseException;
import java.util.Date;
+import javax.swing.DefaultComboBoxModel;
import javax.swing.JComboBox;
import javax.swing.JFormattedTextField;
import javax.swing.JLabel;
@@ -40,7 +40,6 @@
import org.jdesktop.swingx.JXTextArea;
import org.jdesktop.swingx.JXTextField;
-import edu.wpi.cs.wpisuitetng.modules.core.models.User;
import edu.wpi.cs.wpisuitetng.modules.taskmanager.model.TaskModel;
import edu.wpi.cs.wpisuitetng.modules.taskmanager.presenter.TaskPresenter;
@@ -53,16 +52,18 @@
private int index;
private ViewMode viewMode;
+
private JComboBox<BucketView> statusComboBox = new JComboBox<BucketView>();
private Color colorsOptions[] = { Color.WHITE, Color.YELLOW, Color.RED, Color.GREEN, Color.MAGENTA, Color.GRAY};
private JComboBox<Color> colorComboBox = new JComboBox <Color>(colorsOptions);
private JLabel taskNameLabel = new JLabel("Task Name:");
private JLabel dateLabel = new JLabel("Due Date:");
+ private JLabel statusLabel = new JLabel("Status:");
private JLabel actualEffortLabel = new JLabel("Actual Effort:");
private JLabel estEffortLabel = new JLabel("Estimated Effort:");
private JLabel changeColorLabel = new JLabel ("Category:");
private TaskButtonsPanel buttonPanel;
- private JTabbedPane commentPanel = new CommentView(this.viewMode);
+ private JTabbedPane commentPanel=new CommentView(this.viewMode);
private JPanel descriptionPanel = new JPanel();
private JPanel detailsPanel = new JPanel();
private JPanel infoPanel = new JPanel();
@@ -138,21 +139,28 @@
this.infoPanel.add(taskNameField, "cell 1 0 2 1, grow");
this.infoPanel.add(dateLabel, "cell 0 1");
this.infoPanel.add(datePicker, "cell 1 1, grow");
+ statusLabel.setForeground(unmodifiedColor);
+ this.infoPanel.add(statusLabel, "cell 0 2");
+ this.infoPanel.add(statusComboBox, "cell 1 2");
+ this.statusComboBox.setModel(new DefaultComboBoxModel(new String[] {
+ "New", "Selected", "In Progress", "Completed" }));
this.colorComboBox.setRenderer(new ColorRenderer());
this.colorComboBox.setSelectedIndex(0);
this.colorComboBox.setSize(statusComboBox.getSize());
- this.infoPanel.add(actualEffortLabel, "cell 0 2");
- this.infoPanel.add(actualEffortSpinner, "cell 1 2");
- this.actualEffortSpinner.setModel(new SpinnerNumberModel(0, 0, 99999, 1));
- this.infoPanel.add(estEffortLabel, "cell 0 3");
- this.infoPanel.add(estEffortSpinner, "cell 1 3");
+// this.colors.add
+ this.infoPanel.add(actualEffortLabel, "cell 0 3");
+ this.infoPanel.add(actualEffortSpinner, "cell 1 3");
+ this.actualEffortSpinner
+ .setModel(new SpinnerNumberModel(0, 0, 99999, 1));
+ this.infoPanel.add(estEffortLabel, "cell 0 4");
+ this.infoPanel.add(estEffortSpinner, "cell 1 4");
this.estEffortSpinner.setModel(new SpinnerNumberModel(0, 0, 99999, 1));
this.infoPanel.add(changeColorLabel, "cell 0 5");
this.infoPanel.add(colorComboBox, "cell 1 5");
// Format the descriptionPanel layout with components
this.descriptionPanel.add(scrollPane, "cell 0 0,grow");
this.scrollPane
- .setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
+ .setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
this.scrollPane.setViewportView(descriptionMessage);
this.descriptionMessage.setWrapStyleWord(true);
@@ -160,6 +168,7 @@
this.viewMode = viewMode;
//if you are in create mode, then comments are disabled.
((CommentView) this.commentPanel).toggleTextField(this.viewMode) ;
+
DocumentListener validateListener = new DocumentListener() {
/** {@inheritDoc} */
@Override
@@ -183,6 +192,7 @@
ChangeListener changeListener = (ChangeEvent) -> {
validateFields();
};
+
ItemListener itemListener = (ItemListener) -> {
validateFields();
};
@@ -195,9 +205,10 @@
this.actualEffortSpinner.addChangeListener(changeListener);
this.estEffortSpinner.addChangeListener(changeListener);
this.datePicker.getEditor().getDocument()
- .addDocumentListener(validateListener);
+ .addDocumentListener(validateListener);
this.descriptionMessage.getDocument().addDocumentListener(
validateListener);
+ this.statusComboBox.addItemListener(itemListener);
this.colorComboBox.addItemListener(itemListener);
setModel(model);
}
@@ -233,7 +244,15 @@
public void addDeleteOnClickListener(ActionListener listener) {
this.buttonPanel.addDeleteOnClickListener(listener);
}
-
+
+ /**
+ * Adds an action listener to the statusComboBox
+ * @param listener The listener to be added to the ComboBox
+ */
+ public void addChangeStatusListener(ActionListener listener) {
+ this.statusComboBox.addActionListener(listener);
+ }
+
/**
* adds an action listener to the colorComboBox
* @param listener The listener to be added to the ComboBox
@@ -319,7 +338,7 @@
this.viewMode = viewMode;
buttonPanel.validateButtons(viewMode);
}
-
+
/**
* @return The view mode of the task
*/
@@ -328,6 +347,22 @@
}
/**
+ * @return The ID of the selected status
+ */
+ public int getStatus() {
+ return this.statusComboBox.getSelectedIndex() + 1;
+ }
+
+ /**
+ * set the status view for the ComboBox
+ * @param status the status of the task
+ */
+ public void setStatus(int status) {
+ System.out.println("setStatus:" + status);
+ statusComboBox.setSelectedIndex(status-1);
+ }
+
+ /**
* Check that all fields are valid and update the user interface to provide
* feedback on what isn't valid.
*/
@@ -417,12 +452,18 @@
} else {
isModified = true;
}
-
+
if (this.presenter.getAssignedUserList().equals(this.model.getAssignedTo())) {
} else {
isModified = true;
}
+ if (this.getStatus() == this.model.getStatus()) {
+ this.statusLabel.setForeground(unmodifiedColor);
+ } else {
+ this.statusLabel.setForeground(modifiedColor);
+ isModified = true;
+ }
if(this.model.getLabelColor()==null){
if(this.colorComboBox.getSelectedItem().equals(new Color(255,255,255))){
this.changeColorLabel.setForeground(unmodifiedColor);
@@ -436,6 +477,7 @@
this.changeColorLabel.setForeground(modifiedColor);
isModified = true;
}
+
/* The date value might be null */
boolean datesAreEqual;
if (this.getDueDate() == null && this.model.getDueDate() == null) {
@@ -457,16 +499,11 @@
* Allow the user to save the task if something is modified and
* everything is still valid.
*/
- if (this.viewMode == viewMode.ARCHIVING){
- this.buttonPanel.setOkEnabledStatus(true);
- }
- else{
this.buttonPanel.setOkEnabledStatus(isValid && isModified);
- }
/* Allow the user to reset the fields if something is modified. */
this.buttonPanel.setClearEnabledStatus(isModified);
-
+
/* Don't show cancel dialog if something hasn't been modified. */
this.presenter.setAllowCancelDialogEnabled(isModified);
}
@@ -479,7 +516,7 @@
public CommentView getCommentView() {
return (CommentView) this.commentPanel;
}
-
+
/**
* @return returns the panel that users are on
*/
@@ -494,49 +531,4 @@
public Color getLabelColor() {
return (Color) colorComboBox.getSelectedItem();
}
-
- /**
- * disable editing of task fields within taskView
- */
- public void disableEdits() {
- buttonPanel.setOkEnabledStatus(true);
- this.taskNameField.setEditable(false);
- this.descriptionMessage.setEditable(false);
- this.actualEffortSpinner.setEnabled(false);
- this.estEffortSpinner.setEnabled(false);
- this.datePicker.setEditable(false);
- this.getCommentView().getCommentText().setEditable(false);
- this.taskNameField.setEditable(false);
-
-
- for (Component button : this.getUserListPanel().getAssignedUserListPanel().getComponents()){
- System.out.println("assingedButton" + button);
- button.setEnabled(false);
- }
- for (Component button : this.getUserListPanel().getUnassignedUserListPanel().getComponents()){
- System.out.println("unassignedButton" + button);
- button.setEnabled(false);
- }
-
- }
-
- /**
- * re-enable editing of task fields within a taskView
- */
- public void enableEdits() {
- this.taskNameField.setEditable(true);
- this.descriptionMessage.setEditable(true);
- this.actualEffortSpinner.setEnabled(true);
- this.estEffortSpinner.setEnabled(true);
- this.datePicker.setEditable(true);
- this.getCommentView().getCommentText().setEditable(true);
- this.taskNameField.setEditable(true);
-
- for (Component button : this.getUserListPanel().getAssignedUserListPanel().getComponents()){
- button.setEnabled(true);
- }
- for (Component button : this.getUserListPanel().getUnassignedUserListPanel().getComponents()){
- button.setEnabled(true);
- }
- }
}
diff --git a/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/ToolbarView.java b/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/ToolbarView.java
index 47e2f5a..159e40b 100644
--- a/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/ToolbarView.java
+++ b/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/ToolbarView.java
@@ -13,7 +13,6 @@
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JPanel;
-import javax.swing.JToggleButton;
import edu.wpi.cs.wpisuitetng.modules.taskmanager.presenter.BucketPresenter;
import edu.wpi.cs.wpisuitetng.modules.taskmanager.presenter.TaskPresenter;
@@ -21,14 +20,8 @@
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
-import java.awt.image.BufferedImage;
-import java.io.File;
import java.io.IOException;
import java.util.Date;
-import java.util.Map;
-
-import javax.swing.JLabel;
-import javax.swing.SwingConstants;
/**
* Sets up upper toolbar of TaskManager tab
@@ -41,10 +34,9 @@
/**
* Creates and positions option buttons in upper toolbar
* @param visible boolean
- * @throws IOException
*/
public ToolbarView() {
- setLayout(new MigLayout("fill"));
+ setLayout(new MigLayout("", "[fill]", "[grow]"));
JButton createNewTaskButton = new JButton("<html>Create<br/>Task</html>");
createNewTaskButton.setIcon(Icons.CREATE_TASK_LARGE);
@@ -63,33 +55,7 @@
MainView.getInstance().setSelectedIndex(tabCount-1);
}
});
-
- add(createNewTaskButton, "cell 0 0");
-
- JToggleButton tglbtnArchive = new JToggleButton("<html>Hide<br/>Archived</html>");
- tglbtnArchive.setIcon(Icons.HIDE_ARCHIVE_LARGE);
- tglbtnArchive.setSelected(true);
- add(tglbtnArchive, "cell 0 0");
-
- tglbtnArchive.addActionListener(new ActionListener(){
- public void actionPerformed(ActionEvent e){
- if (tglbtnArchive.isSelected()) {
- /* Show all tasks */
- tglbtnArchive.setText("<html>Hide<br/>Archived</html>");
- MainView.getInstance().setShowArchived(true);
- tglbtnArchive.setIcon(Icons.HIDE_ARCHIVE_LARGE);
- } else {
- /* Only show non-archived tasks */
- tglbtnArchive.setText("<html>Show<br/>Archived</html>");
- MainView.getInstance().setShowArchived(false);
- tglbtnArchive.setIcon(Icons.SHOW_ARCHIVE_LARGE);
- }
-
- MainView.getInstance().resetAllBuckets();
- }
- });
+ add(createNewTaskButton, "cell 0 0");
}
-
-
}
diff --git a/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/UserListsView.java b/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/UserListsView.java
index 4d8ba57..846c3ec 100644
--- a/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/UserListsView.java
+++ b/TaskManager/src/main/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/UserListsView.java
@@ -10,8 +10,6 @@
package edu.wpi.cs.wpisuitetng.modules.taskmanager.view;
-import java.awt.Container;
-
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
@@ -85,17 +83,4 @@
this.unassignedUsersPanel.removeAll();
}
- /**
- * @return the assigned user panel
- */
- public JPanel getAssignedUserListPanel(){
- return this.assignedUsersPanel;
- }
-
- /**
- * @return the unassigned user panel
- */
- public JPanel getUnassignedUserListPanel() {
- return this.unassignedUsersPanel;
- }
}
diff --git a/TaskManager/src/main/resources/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/add_task.png b/TaskManager/src/main/resources/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/add_task.png
deleted file mode 100644
index 2231c6f..0000000
--- a/TaskManager/src/main/resources/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/add_task.png
+++ /dev/null
Binary files differ
diff --git a/TaskManager/src/main/resources/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/add_task_small.png b/TaskManager/src/main/resources/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/add_task_small.png
deleted file mode 100644
index fb55fc5..0000000
--- a/TaskManager/src/main/resources/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/add_task_small.png
+++ /dev/null
Binary files differ
diff --git a/TaskManager/src/main/resources/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/create-task-large.png b/TaskManager/src/main/resources/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/create-task-large.png
index 2c681b3..d26ebff 100644
--- a/TaskManager/src/main/resources/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/create-task-large.png
+++ b/TaskManager/src/main/resources/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/create-task-large.png
Binary files differ
diff --git a/TaskManager/src/main/resources/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/create-task.png b/TaskManager/src/main/resources/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/create-task.png
index baacbd4..2a0907f 100644
--- a/TaskManager/src/main/resources/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/create-task.png
+++ b/TaskManager/src/main/resources/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/create-task.png
Binary files differ
diff --git a/TaskManager/src/main/resources/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/hide-archive-large.png b/TaskManager/src/main/resources/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/hide-archive-large.png
deleted file mode 100644
index 7910b58..0000000
--- a/TaskManager/src/main/resources/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/hide-archive-large.png
+++ /dev/null
Binary files differ
diff --git a/TaskManager/src/main/resources/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/legend.png b/TaskManager/src/main/resources/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/legend.png
deleted file mode 100644
index 5d985db..0000000
--- a/TaskManager/src/main/resources/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/legend.png
+++ /dev/null
Binary files differ
diff --git a/TaskManager/src/main/resources/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/list2.png b/TaskManager/src/main/resources/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/list2.png
deleted file mode 100644
index 0cb326a..0000000
--- a/TaskManager/src/main/resources/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/list2.png
+++ /dev/null
Binary files differ
diff --git a/TaskManager/src/main/resources/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/not_urgent.png b/TaskManager/src/main/resources/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/not_urgent.png
deleted file mode 100644
index 6eb6b5a..0000000
--- a/TaskManager/src/main/resources/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/not_urgent.png
+++ /dev/null
Binary files differ
diff --git a/TaskManager/src/main/resources/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/show-archive-large.png b/TaskManager/src/main/resources/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/show-archive-large.png
deleted file mode 100644
index c09f8b0..0000000
--- a/TaskManager/src/main/resources/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/show-archive-large.png
+++ /dev/null
Binary files differ
diff --git a/TaskManager/src/main/resources/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/task-due-soon.png b/TaskManager/src/main/resources/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/task-due-soon.png
deleted file mode 100644
index bf6b73b..0000000
--- a/TaskManager/src/main/resources/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/task-due-soon.png
+++ /dev/null
Binary files differ
diff --git a/TaskManager/src/main/resources/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/task-due-very-soon.png b/TaskManager/src/main/resources/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/task-due-very-soon.png
deleted file mode 100644
index 19f6892..0000000
--- a/TaskManager/src/main/resources/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/task-due-very-soon.png
+++ /dev/null
Binary files differ
diff --git a/TaskManager/src/main/resources/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/task-edit.png b/TaskManager/src/main/resources/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/task-edit.png
deleted file mode 100644
index 7b6a934..0000000
--- a/TaskManager/src/main/resources/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/task-edit.png
+++ /dev/null
Binary files differ
diff --git a/TaskManager/src/main/resources/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/task-normal.png b/TaskManager/src/main/resources/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/task-normal.png
deleted file mode 100644
index c10b3e2..0000000
--- a/TaskManager/src/main/resources/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/task-normal.png
+++ /dev/null
Binary files differ
diff --git a/TaskManager/src/main/resources/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/task-overdue.png b/TaskManager/src/main/resources/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/task-overdue.png
deleted file mode 100644
index f67622c..0000000
--- a/TaskManager/src/main/resources/edu/wpi/cs/wpisuitetng/modules/taskmanager/view/task-overdue.png
+++ /dev/null
Binary files differ
diff --git a/TaskManager/src/test/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/model/TestActivity.java b/TaskManager/src/test/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/model/TestActivity.java
deleted file mode 100644
index 61338a5..0000000
--- a/TaskManager/src/test/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/model/TestActivity.java
+++ /dev/null
@@ -1,90 +0,0 @@
-package edu.wpi.cs.wpisuitetng.modules.taskmanager.model;
-
-import static org.junit.Assert.*;
-
-import java.util.Date;
-
-import org.junit.Test;
-
-import edu.wpi.cs.wpisuitetng.modules.core.models.User;
-
-public class TestActivity {
-
- @Test
- public void testCreateNonNullActivity() {
- assertNotNull(new ActivityModel());
- ActivityModel actMod = new ActivityModel(1, new User(null, null, null,
- 1), "Activity", new Date(), true);
- }
-
- @Test
- public void testIsAutogen() {
- ActivityModel actMod = new ActivityModel();
- assertEquals(false, actMod.getIsAutogen());
- actMod.setIsAutogen(true);
- assertEquals(true, actMod.getIsAutogen());
- }
-
- @Test
- public void testDate() {
- ActivityModel actMod = new ActivityModel();
- assertEquals(new Date(), actMod.getDate());
- actMod.setDate(new Date(1, 1, 2014));
- assertEquals(new Date(1, 1, 2014), actMod.getDate());
- }
-
- @Test
- public void testID() {
- ActivityModel actMod = new ActivityModel();
- assertEquals(-1, actMod.getId());
- actMod.setId(1);
- assertEquals(1, actMod.getId());
- }
-
- @Test
- public void testUser() {
- ActivityModel actMod = new ActivityModel();
- assertEquals(-1, actMod.getUser());
- actMod.setUser(new User(null, null, null, 1));
- assertEquals(1, actMod.getUser());
- }
-
- @Test
- public void testActivity() {
- ActivityModel actMod = new ActivityModel();
- assertEquals("", actMod.getActivity());
- actMod.setActivity("Activity");
- assertEquals("Activity", actMod.getActivity());
- }
-
- @Test
- public void testCopyFrom() {
- ActivityModel actMod1 = new ActivityModel(1, new User(null, null, null,
- 1), "Activity", new Date(), true);
- ActivityModel actMod2 = new ActivityModel();
- actMod2.copyFrom(actMod1);
- assertEquals(actMod2.getId(), actMod1.getId());
- assertEquals(actMod2.getActivity(), actMod1.getActivity());
- assertEquals(actMod2.getDate(), actMod1.getDate());
- assertEquals(actMod2.getIsAutogen(), actMod1.getIsAutogen());
- assertEquals(actMod2.getUser(), actMod1.getUser());
- }
-
- @Test
- public void testToJson() {
- ActivityModel actMod = new ActivityModel();
- actMod.setDate(new Date(12, 10, 2014));
- String json = "{\"id\":-1,\"userId\":-1,\"date\":\"May 7, 1918 12:00:00 AM\",\"activity\":\"\",\"isAutogen\":false,\"permissionMap\":{}}";
- assertEquals(json, actMod.toJson());
- }
-
- @Test
- public void testFromJson() {
- ActivityModel actMod1 = new ActivityModel();
- ActivityModel actMod2 = new ActivityModel();
- actMod1.setDate(new Date(12,10,2014));
- actMod2.setDate(new Date(12,10,2014));
- String json = "{\"id\":-1,\"userId\":-1,\"date\":\"May 7, 1918 12:00:00 AM\",\"activity\":\"\",\"isAutogen\":false,\"permissionMap\":{}}";
- assertTrue(actMod1.fromJson(json).isEqual(actMod2.fromJson(json)));
- }
-}
diff --git a/TaskManager/src/test/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/model/TestTask.java b/TaskManager/src/test/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/model/TestTask.java
index 19a1cc3..35828cc 100644
--- a/TaskManager/src/test/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/model/TestTask.java
+++ b/TaskManager/src/test/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/model/TestTask.java
@@ -1,12 +1,3 @@
-/*******************************************************************************
- * Copyright (c) 2014 -- WPI Suite
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- ******************************************************************************/
package edu.wpi.cs.wpisuitetng.modules.taskmanager.model;
import static org.junit.Assert.*;
@@ -24,7 +15,6 @@
/**
* Tests methods in iteration.java and tests the creation of variants of Bucket
*
- *@author theFloorIsJava
*/
public class TestTask {
diff --git a/TaskManager/src/test/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/model/TestWorkflowModel.java b/TaskManager/src/test/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/model/TestWorkflowModel.java
deleted file mode 100644
index f12f8ff..0000000
--- a/TaskManager/src/test/java/edu/wpi/cs/wpisuitetng/modules/taskmanager/model/TestWorkflowModel.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2014 -- WPI Suite
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- ******************************************************************************/
-package edu.wpi.cs.wpisuitetng.modules.taskmanager.model;
-
-import static org.junit.Assert.*;
-
-import java.awt.Color;
-import java.util.ArrayList;
-
-import org.junit.Test;
-/**
- * test workflowModel's methods
- * @author theFloorIsJava
- *
- */
-public class TestWorkflowModel {
-
- @Test
- public final void testWorkflowModel() {
- WorkflowModel test = new WorkflowModel();
- assertEquals(-1, test.getId());
- assertEquals("", test.getTitle());
- assertEquals(new ArrayList<>(), test.getBucketIds());
- }
-
- @Test
- public final void testWorkflowModelIntString() {
- WorkflowModel test = new WorkflowModel(10, "Due Soon");
- assertEquals(10, test.getId());
- assertEquals("Due Soon", test.getTitle());
- assertEquals(new ArrayList<>(), test.getBucketIds());
- }
-
- @Test
- public final void testToJson() {
- WorkflowModel test = new WorkflowModel(10, "Due Soon");
- assertEquals("{\"id\":10,\"title\":\"Due Soon\",\"bucketIds\":[],\"permissionMap\":{}}" ,test.toJson());
- }
-
- @Test
- public final void testFromJson() {
- String json="{\"id\":10,\"title\":\"Due Soon\",\"bucketIds\":[],\"permissionMap\":{}}";
- WorkflowModel test = new WorkflowModel(10, "Due Soon");
- WorkflowModel test2 = new WorkflowModel(10, "Due Soon");
- assertTrue(test.fromJson(json).equals(test2.fromJson(json)));
- }
-
- @Test
- public final void testIdentify() {
- WorkflowModel test = new WorkflowModel(10, "Due Soon");
- WorkflowModel test2 = new WorkflowModel(20, "also a workflowmodel obj");
- assertTrue(test.identify(test) );
- assertFalse(test.identify(new Color ( 0,0,0)));
- }
-
- @Test
- public final void testGetBucketIds() {
- WorkflowModel test = new WorkflowModel(10, "Due Soon");
- test.getBucketIds().add(4);
- ArrayList <Integer> list = new ArrayList<Integer>();
- list.add(4);
-
- assertEquals(test.getBucketIds(),list );
- }
-
- @Test
- public final void testSetBucketIds() {
- WorkflowModel test = new WorkflowModel(10, "Due Soon");
- ArrayList <Integer> list = new ArrayList<Integer>();
- list.add(4);
- test.setBucketIds(list);
- assertEquals(test.getBucketIds(), list);
- }
-
- @Test
- public final void testGetTitle() {
- WorkflowModel test = new WorkflowModel(10, "Due Soon");
- assertEquals("Due Soon", test.getTitle());
- }
-
- @Test
- public final void testSetTitle() {
- WorkflowModel test = new WorkflowModel(10, "Due Soon");
- test.setTitle("new title");
- assertEquals("new title", test.getTitle());
- }
-
- @Test
- public final void testGetId() {
- WorkflowModel test = new WorkflowModel(10, "Due Soon");
- assertEquals(10, test.getId());
- }
-
- @Test
- public final void testSetId() {
- WorkflowModel test = new WorkflowModel(10, "Due Soon");
- test.setId(11);
- assertEquals(11, test.getId());
- }
-
- @Test
- public final void testCopyFrom() {
- WorkflowModel empty = new WorkflowModel();
- WorkflowModel copy=new WorkflowModel(99, "copied from");
- empty.copyFrom(copy);
- assertEquals(empty.getId(), 99);
- assertEquals(empty.getTitle(), "copied from");
- assertEquals(empty.getBucketIds(), new ArrayList<>());
- }
-
-}