Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkersten2005-06-28 16:04:15 -0400
committermkersten2005-06-28 16:04:15 -0400
commit932fc5f59db39918959e5f9169fd12434990b0f8 (patch)
treef063cbdb7a10054ecfc60c38f905e035b0c5b8c8 /org.eclipse.mylyn.tasks.ui
parent1123b519e0aa910569f801d7d2545c1aaea1266d (diff)
downloadorg.eclipse.mylyn.tasks-932fc5f59db39918959e5f9169fd12434990b0f8.tar.gz
org.eclipse.mylyn.tasks-932fc5f59db39918959e5f9169fd12434990b0f8.tar.xz
org.eclipse.mylyn.tasks-932fc5f59db39918959e5f9169fd12434990b0f8.zip
Ken's patch for Bug 101149
task list priority filter
Diffstat (limited to 'org.eclipse.mylyn.tasks.ui')
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/MylarTasksPlugin.java119
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/views/TaskListView.java56
2 files changed, 142 insertions, 33 deletions
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/MylarTasksPlugin.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/MylarTasksPlugin.java
index fe26e009c..061cc0fd2 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/MylarTasksPlugin.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/MylarTasksPlugin.java
@@ -11,12 +11,14 @@
package org.eclipse.mylar.tasks;
import java.io.File;
+import java.util.ArrayList;
import java.util.List;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import org.eclipse.core.runtime.Preferences.IPropertyChangeListener;
import org.eclipse.core.runtime.Preferences.PropertyChangeEvent;
+import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.mylar.core.MylarPlugin;
import org.eclipse.mylar.tasks.bugzilla.BugzillaContentProvider;
import org.eclipse.mylar.tasks.bugzilla.BugzillaEditingMonitor;
@@ -48,8 +50,45 @@ public class MylarTasksPlugin extends AbstractUIPlugin implements IStartup {
public static final String TASK_ID = "org.eclipse.mylar.tasks.userid";
public static final String DEFAULT_TASK_LIST_FILE = "tasklist" + FILE_EXTENSION;
public static final String TASK_EDITOR_ID = "org.eclipse.mylar.tasks.ui.taskEditor";
+ public static final String SHOW_P1_MODE = "org.eclipse.mylar.tasks.show.p1";
+ public static final String SHOW_P2_MODE = "org.eclipse.mylar.tasks.show.p2";
+ public static final String SHOW_P3_MODE = "org.eclipse.mylar.tasks.show.p3";
+ public static final String SHOW_P4_MODE = "org.eclipse.mylar.tasks.show.p4";
+ public static final String SHOW_P5_MODE = "org.eclipse.mylar.tasks.show.p5";
+ public static final String FILTER_COMPLETE_MODE = "org.eclipse.mylar.tasks.filter.complete";
+ public static final String FILTER_INCOMPLETE_MODE = "org.eclipse.mylar.tasks.filter.incomplete";
+
private ResourceBundle resourceBundle;
+ public enum Priority_Level {
+ P1,
+ P2,
+ P3,
+ P4,
+ P5;
+
+ @Override
+ public String toString() {
+ switch(this) {
+ case P1: return "P1";
+ case P2: return "P2";
+ case P3: return "P3";
+ case P4: return "P4";
+ case P5: return "P5";
+ default: return "null";
+ }
+ }
+ public static Priority_Level fromString(String string) {
+ if (string == null) return null;
+ if (string.equals("P1")) return P1;
+ if (string.equals("P2")) return P2;
+ if (string.equals("P3")) return P3;
+ if (string.equals("P4")) return P4;
+ if (string.equals("P5")) return P5;
+ return null;
+ }
+ }
+
/** The bridge between Bugzilla and mylar */
private static BugzillaMylarBridge bridge = null;
@@ -137,6 +176,11 @@ public class MylarTasksPlugin extends AbstractUIPlugin implements IStartup {
Workbench.getInstance().getActiveWorkbenchWindow().getShell().addShellListener(SHELL_LISTENER);
MylarPlugin.getDefault().getPluginPreferences().addPropertyChangeListener(PREFERENCE_LISTENER);
+ getPrefs().setDefault(SHOW_P1_MODE, true);
+ getPrefs().setDefault(SHOW_P2_MODE, true);
+ getPrefs().setDefault(SHOW_P3_MODE, true);
+ getPrefs().setDefault(SHOW_P4_MODE, true);
+ getPrefs().setDefault(SHOW_P5_MODE, true);
if (window != null) {
// create a new bridge and initialize it
bridge = new BugzillaMylarBridge();
@@ -234,4 +278,79 @@ public class MylarTasksPlugin extends AbstractUIPlugin implements IStartup {
return referencesProvider;
}
+
+ public static IPreferenceStore getPrefs() {
+ return MylarPlugin.getDefault().getPreferenceStore();
+ }
+
+ public static void setPriorityLevel(Priority_Level pl, boolean showPriority) {
+ String key = "";
+ switch(pl) {
+ case P1: key = SHOW_P1_MODE; break;
+ case P2: key = SHOW_P2_MODE; break;
+ case P3: key = SHOW_P3_MODE; break;
+ case P4: key = SHOW_P4_MODE; break;
+ case P5: key = SHOW_P5_MODE; break;
+ default: key = SHOW_P1_MODE; break;
+ }
+ getPrefs().setValue(key, showPriority);
+ }
+ public static boolean getPriorityLevel(Priority_Level pl) {
+ String key = "";
+ switch(pl) {
+ case P1: key = SHOW_P1_MODE; break;
+ case P2: key = SHOW_P2_MODE; break;
+ case P3: key = SHOW_P3_MODE; break;
+ case P4: key = SHOW_P4_MODE; break;
+ case P5: key = SHOW_P5_MODE; break;
+ default: key = SHOW_P1_MODE; break;
+ }
+ if(getPrefs().contains(key)) {
+ return getPrefs().getBoolean(key);
+ } else {
+ return true;
+ }
+ }
+ public static List<Priority_Level> getPriorityLevels() {
+ List<Priority_Level> levels = new ArrayList<Priority_Level>();
+ if (getPriorityLevel(Priority_Level.P1)) {
+ levels.add(Priority_Level.P1);
+ }
+ if (getPriorityLevel(Priority_Level.P2)) {
+ levels.add(Priority_Level.P2);
+ }
+ if (getPriorityLevel(Priority_Level.P3)) {
+ levels.add(Priority_Level.P3);
+ }
+ if (getPriorityLevel(Priority_Level.P4)) {
+ levels.add(Priority_Level.P4);
+ }
+ if (getPriorityLevel(Priority_Level.P5)) {
+ levels.add(Priority_Level.P5);
+ }
+ return levels;
+ }
+ public void setFilterCompleteMode(boolean isFilterOn) {
+ getPrefs().setValue(FILTER_COMPLETE_MODE, isFilterOn);
+ }
+
+ public boolean isFilterCompleteMode() {
+ if (getPrefs().contains(FILTER_COMPLETE_MODE)) {
+ return getPrefs().getBoolean(FILTER_COMPLETE_MODE);
+ } else {
+ return false;
+ }
+ }
+
+ public void setFilterInCompleteMode(boolean isFilterOn) {
+ getPrefs().setValue(FILTER_INCOMPLETE_MODE, isFilterOn);
+ }
+
+ public boolean isFilterInCompleteMode() {
+ if (getPrefs().contains(FILTER_INCOMPLETE_MODE)) {
+ return getPrefs().getBoolean(FILTER_INCOMPLETE_MODE);
+ } else {
+ return false;
+ }
+ }
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/views/TaskListView.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/views/TaskListView.java
index 4d2ed08f9..454b5e307 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/views/TaskListView.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/views/TaskListView.java
@@ -61,6 +61,7 @@ import org.eclipse.mylar.tasks.Category;
import org.eclipse.mylar.tasks.ITask;
import org.eclipse.mylar.tasks.MylarTasksPlugin;
import org.eclipse.mylar.tasks.Task;
+import org.eclipse.mylar.tasks.MylarTasksPlugin.Priority_Level;
import org.eclipse.mylar.tasks.bugzilla.BugzillaStructureBridge;
import org.eclipse.mylar.tasks.ui.BugzillaTaskEditorInput;
import org.eclipse.mylar.tasks.ui.TaskEditorInput;
@@ -139,7 +140,7 @@ public class TaskListView extends ViewPart {
public static final String tableSortIdentifier = "org.eclipse.mylar.tasks.ui.views.tasklist.sortIndex";
private int sortIndex = 2;
- private String[] PRIORITY_LEVELS = { "P1", "P2", "P3", "P4", "P5" };
+ private String[] PRIORITY_LEVELS = { "P1", "P2", "P3", "P4", "P5" };
private final class MoveTaskToRootAction extends Action {
public MoveTaskToRootAction() {
@@ -174,12 +175,12 @@ public class TaskListView extends ViewPart {
setText("Filter Incomplete tasks");
setToolTipText("Filter Incomplete tasks");
setImageDescriptor(MylarImages.TASK_INACTIVE);
- setChecked(MylarUiPlugin.getDefault().isFilterInCompleteMode());
+ setChecked(MylarTasksPlugin.getDefault().isFilterInCompleteMode());
}
@Override
public void run() {
- MylarUiPlugin.getDefault().setFilterInCompleteMode(isChecked());
+ MylarTasksPlugin.getDefault().setFilterInCompleteMode(isChecked());
if (isChecked()) {
viewer.addFilter(inCompleteFilter);
filterCompleteTask.setChecked(false);
@@ -196,11 +197,11 @@ public class TaskListView extends ViewPart {
setText("Filter Complete tasks");
setToolTipText("Filter Completed tasks");
setImageDescriptor(MylarImages.TASK_ACTIVE);
- setChecked(MylarUiPlugin.getDefault().isFilterCompleteMode());
+ setChecked(MylarTasksPlugin.getDefault().isFilterCompleteMode());
}
@Override
public void run() {
- MylarUiPlugin.getDefault().setFilterCompleteMode(isChecked());
+ MylarTasksPlugin.getDefault().setFilterCompleteMode(isChecked());
if (isChecked()) {
viewer.addFilter(completeFilter);
filterInCompleteTask.setChecked(false);
@@ -504,6 +505,7 @@ public class TaskListView extends ViewPart {
private Menu dropDownMenu = null;
public PriorityDropDownAction() {
+ super();
setText("Display Priorities");
setToolTipText("Show Tasks with Priority Levels");
setImageDescriptor(MylarImages.FILTER_DECLARATIONS);
@@ -539,7 +541,7 @@ public class TaskListView extends ViewPart {
Action P1 = new Action(PRIORITY_LEVELS[0], AS_CHECK_BOX) {
@Override
public void run() {
- MylarUiPlugin.getDefault().setP1FilterMode(!isChecked());
+ MylarTasksPlugin.setPriorityLevel(MylarTasksPlugin.Priority_Level.P1, isChecked());
if (isChecked()) {
priorityFilter.displayPriority(PRIORITY_LEVELS[0]);
} else {
@@ -549,7 +551,7 @@ public class TaskListView extends ViewPart {
}
};
P1.setEnabled(true);
- P1.setChecked(!MylarUiPlugin.getDefault().isP1FilterMode());
+ P1.setChecked(MylarTasksPlugin.getPriorityLevel(MylarTasksPlugin.Priority_Level.P1));
P1.setToolTipText(PRIORITY_LEVELS[0]);
ActionContributionItem item= new ActionContributionItem(P1);
item.fill(dropDownMenu, -1);
@@ -557,7 +559,7 @@ public class TaskListView extends ViewPart {
Action P2 = new Action(PRIORITY_LEVELS[1], AS_CHECK_BOX) {
@Override
public void run() {
- MylarUiPlugin.getDefault().setP2FilterMode(!isChecked());
+ MylarTasksPlugin.setPriorityLevel(MylarTasksPlugin.Priority_Level.P2, isChecked());
if (isChecked()) {
priorityFilter.displayPriority(PRIORITY_LEVELS[1]);
} else {
@@ -567,7 +569,7 @@ public class TaskListView extends ViewPart {
}
};
P2.setEnabled(true);
- P2.setChecked(!MylarUiPlugin.getDefault().isP2FilterMode());
+ P2.setChecked(MylarTasksPlugin.getPriorityLevel(MylarTasksPlugin.Priority_Level.P2));
P2.setToolTipText(PRIORITY_LEVELS[1]);
item= new ActionContributionItem(P2);
item.fill(dropDownMenu, -1);
@@ -575,7 +577,7 @@ public class TaskListView extends ViewPart {
Action P3 = new Action(PRIORITY_LEVELS[2], AS_CHECK_BOX) {
@Override
public void run() {
- MylarUiPlugin.getDefault().setP3FilterMode(!isChecked());
+ MylarTasksPlugin.setPriorityLevel(MylarTasksPlugin.Priority_Level.P3, isChecked());
if (isChecked()) {
priorityFilter.displayPriority(PRIORITY_LEVELS[2]);
} else {
@@ -585,7 +587,7 @@ public class TaskListView extends ViewPart {
}
};
P3.setEnabled(true);
- P3.setChecked(!MylarUiPlugin.getDefault().isP3FilterMode());
+ P3.setChecked(MylarTasksPlugin.getPriorityLevel(MylarTasksPlugin.Priority_Level.P3));
P3.setToolTipText(PRIORITY_LEVELS[2]);
item= new ActionContributionItem(P3);
item.fill(dropDownMenu, -1);
@@ -593,7 +595,7 @@ public class TaskListView extends ViewPart {
Action P4 = new Action(PRIORITY_LEVELS[3], AS_CHECK_BOX) {
@Override
public void run() {
- MylarUiPlugin.getDefault().setP4FilterMode(!isChecked());
+ MylarTasksPlugin.setPriorityLevel(MylarTasksPlugin.Priority_Level.P4, isChecked());
if (isChecked()) {
priorityFilter.displayPriority(PRIORITY_LEVELS[3]);
} else {
@@ -603,7 +605,7 @@ public class TaskListView extends ViewPart {
}
};
P4.setEnabled(true);
- P4.setChecked(!MylarUiPlugin.getDefault().isP4FilterMode());
+ P4.setChecked(MylarTasksPlugin.getPriorityLevel(MylarTasksPlugin.Priority_Level.P4));
P4.setToolTipText(PRIORITY_LEVELS[3]);
item= new ActionContributionItem(P4);
item.fill(dropDownMenu, -1);
@@ -611,7 +613,7 @@ public class TaskListView extends ViewPart {
Action P5 = new Action(PRIORITY_LEVELS[4], AS_CHECK_BOX) {
@Override
public void run() {
- MylarUiPlugin.getDefault().setP5FilterMode(!isChecked());
+ MylarTasksPlugin.setPriorityLevel(MylarTasksPlugin.Priority_Level.P5, isChecked());
if (isChecked()) {
priorityFilter.displayPriority(PRIORITY_LEVELS[4]);
} else {
@@ -621,12 +623,13 @@ public class TaskListView extends ViewPart {
}
};
P5.setEnabled(true);
- P5.setChecked(!MylarUiPlugin.getDefault().isP5FilterMode());
+ P5.setChecked(MylarTasksPlugin.getPriorityLevel(MylarTasksPlugin.Priority_Level.P5));
P5.setToolTipText(PRIORITY_LEVELS[4]);
item= new ActionContributionItem(P5);
item.fill(dropDownMenu, -1);
}
- public void run() {
+ public void run() {
+ this.setChecked(isChecked());
}
}
@@ -661,21 +664,8 @@ public class TaskListView extends ViewPart {
private List<String> priorities = new ArrayList<String>();
public PriorityFilter() {
- // if filter is off, then add to list
- if (!MylarUiPlugin.getDefault().isP1FilterMode()) {
- displayPriority("P1");
- }
- if (!MylarUiPlugin.getDefault().isP2FilterMode()) {
- displayPriority("P2");
- }
- if (!MylarUiPlugin.getDefault().isP3FilterMode()) {
- displayPriority("P3");
- }
- if (!MylarUiPlugin.getDefault().isP4FilterMode()) {
- displayPriority("P4");
- }
- if (!MylarUiPlugin.getDefault().isP5FilterMode()) {
- displayPriority("P5");
+ for (Priority_Level level : MylarTasksPlugin.getPriorityLevels()) {
+ displayPriority(level.toString());
}
}
@@ -976,8 +966,8 @@ public class TaskListView extends ViewPart {
}
viewer.setSorter(new TaskListTableSorter(columnNames[sortIndex]));
viewer.addFilter(priorityFilter);
- if(MylarUiPlugin.getDefault().isFilterInCompleteMode()) viewer.addFilter(inCompleteFilter);
- if(MylarUiPlugin.getDefault().isFilterCompleteMode()) viewer.addFilter(completeFilter);
+ if(MylarTasksPlugin.getDefault().isFilterInCompleteMode()) viewer.addFilter(inCompleteFilter);
+ if(MylarTasksPlugin.getDefault().isFilterCompleteMode()) viewer.addFilter(completeFilter);
viewer.refresh();
}

Back to the top