Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsminto2005-07-28 22:16:07 +0000
committersminto2005-07-28 22:16:07 +0000
commita378690edce0ec78a35574c7df9530e302120f25 (patch)
treeed19df166765cba215d1ff8cd03ed989a84a6d55 /org.eclipse.mylyn.tasks.ui
parentb0c5396f93f5359d70e474a057be56e2ec9cba39 (diff)
downloadorg.eclipse.mylyn.tasks-a378690edce0ec78a35574c7df9530e302120f25.tar.gz
org.eclipse.mylyn.tasks-a378690edce0ec78a35574c7df9530e302120f25.tar.xz
org.eclipse.mylyn.tasks-a378690edce0ec78a35574c7df9530e302120f25.zip
applied kens patch for Bug 105097 add back/forward buttons to task list
Diffstat (limited to 'org.eclipse.mylyn.tasks.ui')
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/MylarTasklistPlugin.java5
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/actions/NextTaskAction.java51
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/actions/PreviousTaskAction.java49
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/views/TaskActivationHistory.java65
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/views/TaskListView.java49
5 files changed, 216 insertions, 3 deletions
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/MylarTasklistPlugin.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/MylarTasklistPlugin.java
index ff4a64c3b..c1c28a475 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/MylarTasklistPlugin.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/MylarTasklistPlugin.java
@@ -27,6 +27,7 @@ import org.eclipse.core.runtime.Preferences.PropertyChangeEvent;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.mylar.core.MylarPlugin;
import org.eclipse.mylar.tasklist.internal.TaskListExternalizer;
+import org.eclipse.mylar.tasklist.ui.views.TaskListView;
import org.eclipse.swt.events.ShellEvent;
import org.eclipse.swt.events.ShellListener;
import org.eclipse.ui.IWorkbench;
@@ -227,6 +228,10 @@ public class MylarTasklistPlugin extends AbstractUIPlugin {
String path = MylarPlugin.getDefault().getUserDataDirectory() + File.separator + DEFAULT_TASK_LIST_FILE;
getTaskListManager().setTaskListFile(new File(path));
}
+ } else if (event.getProperty().equals(MULTIPLE_ACTIVE_TASKS)) {
+ TaskListView.getDefault().togglePreviousAction(!getPrefs().getBoolean(MULTIPLE_ACTIVE_TASKS));
+ TaskListView.getDefault().toggleNextAction(!getPrefs().getBoolean(MULTIPLE_ACTIVE_TASKS));
+ TaskListView.getDefault().clearTaskHistory();
} else {
}
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/actions/NextTaskAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/actions/NextTaskAction.java
new file mode 100644
index 000000000..379de183a
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/actions/NextTaskAction.java
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2004 - 2005 University Of British Columbia and others.
+ * 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
+ *
+ * Contributors:
+ * University Of British Columbia - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylar.tasklist.ui.actions;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.mylar.tasklist.ui.views.TaskActivationHistory;
+import org.eclipse.mylar.tasklist.ui.views.TaskListView;
+
+/**
+ * @author Ken Sueda
+ */
+public class NextTaskAction extends Action {
+
+ public static final String ID = "org.eclipse.mylar.tasklist.actions.task.next";
+
+ private final TaskListView view;
+ private TaskActivationHistory taskHistory;
+
+ public NextTaskAction(TaskListView view, TaskActivationHistory history) {
+ this.view = view;
+ taskHistory = history;
+ setText("Next Task");
+ setToolTipText("Next Task");
+ setId(ID);
+ setEnabled(false);
+// setImageDescriptor(TaskListImages.CATEGORY_NEW);
+ }
+
+ @Override
+ public void run() {
+ if (taskHistory.hasNext()) {
+ new TaskActivateAction(taskHistory.getNextTask()).run();
+ if (!taskHistory.hasNext()) {
+ setEnabled(false);
+ }
+ if (taskHistory.hasPrevious()) {
+ view.getPreviousTaskAction().setEnabled(true);
+ }
+ view.getViewer().refresh();
+ }
+ }
+}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/actions/PreviousTaskAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/actions/PreviousTaskAction.java
new file mode 100644
index 000000000..ca089eb6b
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/actions/PreviousTaskAction.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * Copyright (c) 2004 - 2005 University Of British Columbia and others.
+ * 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
+ *
+ * Contributors:
+ * University Of British Columbia - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.mylar.tasklist.ui.actions;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.mylar.tasklist.ui.views.TaskActivationHistory;
+import org.eclipse.mylar.tasklist.ui.views.TaskListView;
+
+/**
+ * @author Ken Sueda
+ */
+public class PreviousTaskAction extends Action {
+ public static final String ID = "org.eclipse.mylar.tasklist.actions.tas.previous";
+
+ private final TaskListView view;
+ private TaskActivationHistory taskHistory;
+
+ public PreviousTaskAction(TaskListView view, TaskActivationHistory history) {
+ this.view = view;
+ taskHistory = history;
+ setText("Previous Task");
+ setToolTipText("Previous Task");
+ setId(ID);
+ setEnabled(false);
+// setImageDescriptor(TaskListImages.CATEGORY_NEW);
+ }
+
+ @Override
+ public void run() {
+ if (taskHistory.hasPrevious()) {
+ new TaskActivateAction(taskHistory.getPreviousTask()).run();
+ if (!taskHistory.hasPrevious()) {
+ setEnabled(false);
+ }
+ if (taskHistory.hasNext()) {
+ view.getNextTaskAction().setEnabled(true);
+ }
+ view.getViewer().refresh();
+ }
+ }
+}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/views/TaskActivationHistory.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/views/TaskActivationHistory.java
new file mode 100644
index 000000000..f4d4186a6
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/views/TaskActivationHistory.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2004 - 2005 University Of British Columbia and others.
+ * 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
+ *
+ * Contributors:
+ * University Of British Columbia - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.mylar.tasklist.ui.views;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.mylar.tasklist.ITask;
+
+/**
+ * @author Ken Sueda
+ */
+public class TaskActivationHistory {
+ private List<ITask> history = new ArrayList<ITask>();
+ private int currentIndex = -1;
+
+ public TaskActivationHistory() {
+ }
+
+ public void addTask(ITask task) {
+ if (hasNext()) {
+ for (int i = currentIndex+1; i < history.size();) {
+ history.remove(i);
+ }
+ }
+ history.add(task);
+ currentIndex++;
+ }
+
+ public ITask getPreviousTask() {
+ if (hasPrevious()) {
+ return history.get(--currentIndex);
+ } else {
+ return null;
+ }
+ }
+
+ public boolean hasPrevious() {
+ return currentIndex > 0;
+ }
+
+ public ITask getNextTask() {
+ if (hasNext()) {
+ return history.get(++currentIndex);
+ } else {
+ return null;
+ }
+ }
+
+ public boolean hasNext() {
+ return currentIndex < history.size() - 1;
+ }
+
+ public void clear() {
+ history.clear();
+ }
+}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/views/TaskListView.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/views/TaskListView.java
index cacd188e5..e58bbd055 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/views/TaskListView.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/views/TaskListView.java
@@ -68,7 +68,9 @@ import org.eclipse.mylar.tasklist.ui.actions.DeleteAction;
import org.eclipse.mylar.tasklist.ui.actions.FilterCompletedTasksAction;
import org.eclipse.mylar.tasklist.ui.actions.MarkTaskCompleteAction;
import org.eclipse.mylar.tasklist.ui.actions.MarkTaskIncompleteAction;
+import org.eclipse.mylar.tasklist.ui.actions.NextTaskAction;
import org.eclipse.mylar.tasklist.ui.actions.OpenTaskEditorAction;
+import org.eclipse.mylar.tasklist.ui.actions.PreviousTaskAction;
import org.eclipse.mylar.tasklist.ui.actions.TaskActivateAction;
import org.eclipse.mylar.tasklist.ui.actions.TaskDeactivateAction;
import org.eclipse.swt.SWT;
@@ -122,6 +124,8 @@ public class TaskListView extends ViewPart {
private DeleteAction delete;
private OpenTaskEditorAction doubleClickAction;
+ private PreviousTaskAction previousTaskAction;
+ private NextTaskAction nextTaskAction;
//private Action toggleIntersectionModeAction = new ToggleIntersectionModeAction();
// private Action toggleFilteringAction = new ToggleGlobalInterestFilteringAction();
@@ -145,7 +149,9 @@ public class TaskListView extends ViewPart {
public static final String tableSortIdentifier = "org.eclipse.mylar.tasklist.ui.views.tasklist.sortIndex";
private int sortIndex = 2;
- private static String[] PRIORITY_LEVELS = { "P1", "P2", "P3", "P4", "P5" };
+ private static String[] PRIORITY_LEVELS = { "P1", "P2", "P3", "P4", "P5" };
+
+ private TaskActivationHistory taskHistory = new TaskActivationHistory();
private final class PriorityDropDownAction extends Action implements IMenuCreator {
private Menu dropDownMenu = null;
@@ -597,6 +603,7 @@ public class TaskListView extends ViewPart {
new TaskDeactivateAction(task, INSTANCE).run();
} else {
new TaskActivateAction(task).run();
+ addTaskToHistory(task);
}
getViewer().setSelection(null);
}
@@ -627,6 +634,18 @@ public class TaskListView extends ViewPart {
}
}
+ public void addTaskToHistory(ITask task) {
+ if (!MylarTasklistPlugin.getDefault().isMultipleMode()) {
+ taskHistory.addTask(task);
+ nextTaskAction.setEnabled(taskHistory.hasNext());
+ previousTaskAction.setEnabled(taskHistory.hasPrevious());
+ }
+ }
+
+ public void clearTaskHistory() {
+ taskHistory.clear();
+ }
+
private class TaskListTableSorter extends ViewerSorter {
private String column;
@@ -737,6 +756,10 @@ public class TaskListView extends ViewPart {
// MylarTasklistPlugin.getTaskListManager().getTaskList().addFilter(inCompleteFilter);
if (MylarTasklistPlugin.getDefault().isFilterCompleteMode())
addFilter(COMPLETE_FILTER);
+ if (MylarTasklistPlugin.getDefault().isMultipleMode()) {
+ togglePreviousAction(false);
+ toggleNextAction(false);
+ }
getViewer().refresh();
}
@@ -932,8 +955,10 @@ public class TaskListView extends ViewPart {
private void fillLocalPullDown(IMenuManager manager) {
drillDownAdapter.addNavigationActions(manager);
manager.add(new Separator());
- }
-
+ manager.add(previousTaskAction);
+ manager.add(nextTaskAction);
+ }
+
void fillContextMenu(IMenuManager manager) {
ITaskListElement element = null;;
final Object selectedObject = ((IStructuredSelection)getViewer().getSelection()).getFirstElement();
@@ -1028,8 +1053,26 @@ public class TaskListView extends ViewPart {
filterCompleteTask = new FilterCompletedTasksAction(this);
// filterInCompleteTask = new FilterIncompleteTasksAction();
filterOnPriority = new PriorityDropDownAction();
+ previousTaskAction = new PreviousTaskAction(this, taskHistory);
+ nextTaskAction = new NextTaskAction(this, taskHistory);
}
+
+ public void toggleNextAction(boolean enable) {
+ nextTaskAction.setEnabled(enable);
+ }
+
+ public void togglePreviousAction(boolean enable) {
+ previousTaskAction.setEnabled(enable);
+ }
+
+ public NextTaskAction getNextTaskAction() {
+ return nextTaskAction;
+ }
+
+ public PreviousTaskAction getPreviousTaskAction() {
+ return previousTaskAction;
+ }
/**
* Recursive function that checks for the occurrence of a certain task id.
* All children of the supplied node will be checked.

Back to the top