Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkersten2005-07-04 20:15:28 +0000
committermkersten2005-07-04 20:15:28 +0000
commitdbefc767917635db125e424be4e192ed327a6679 (patch)
tree6097e3c4a849962705e493d4125df4c827f5cbc9
parent1af678420531fbe2bf0eefbcebbd1ef15f306692 (diff)
downloadorg.eclipse.mylyn.tasks-dbefc767917635db125e424be4e192ed327a6679.tar.gz
org.eclipse.mylyn.tasks-dbefc767917635db125e424be4e192ed327a6679.tar.xz
org.eclipse.mylyn.tasks-dbefc767917635db125e424be4e192ed327a6679.zip
Bugzilla Bug 102671 automatic elapsed time for tasks
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/MylarTasksPlugin.java6
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/RefreshBugzillaQueryAction.java72
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/RefreshBugzillaReportsAction.java157
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/views/TaskListView.java35
4 files changed, 193 insertions, 77 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 588142182..2be8b0905 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
@@ -46,6 +46,8 @@ public class MylarTasksPlugin extends AbstractUIPlugin implements IStartup {
private static TaskListManager taskListManager;
private BugzillaContentProvider bugzillaProvider;
+ public static final String REFRESH_QUERIES = "org.eclipse.mylar.tasks.queries.refresh";
+
public static final String FILE_EXTENSION = ".xml";
public static final String TASK_ID = "org.eclipse.mylar.tasks.userid";
public static final String DEFAULT_TASK_LIST_FILE = "tasklist" + FILE_EXTENSION;
@@ -359,4 +361,8 @@ public class MylarTasksPlugin extends AbstractUIPlugin implements IStartup {
return false;
}
}
+
+ public boolean refreshOnStartUpEnabled() {
+ return getPrefs().getBoolean(REFRESH_QUERIES);
+ }
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/RefreshBugzillaQueryAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/RefreshBugzillaQueryAction.java
new file mode 100644
index 000000000..c76c15868
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/RefreshBugzillaQueryAction.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * 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.tasks.ui.actions;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.mylar.core.MylarPlugin;
+import org.eclipse.mylar.tasks.BugzillaQueryCategory;
+import org.eclipse.mylar.tasks.ui.views.TaskListView;
+import org.eclipse.mylar.ui.MylarImages;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+import org.eclipse.ui.progress.IProgressService;
+
+/**
+ * @author Ken Sueda
+ */
+public class RefreshBugzillaQueryAction extends Action {
+ public static final String ID = "org.eclipse.mylar.tasks.actions.refresh.bugquery";
+
+ private final TaskListView view;
+ public RefreshBugzillaQueryAction(TaskListView view) {
+ this.view = view;
+ setText("Refresh Bugzilla Query");
+ setToolTipText("Refresh Bugzilla Query");
+ setId(ID);
+ setImageDescriptor(MylarImages.TASK_BUG_REFRESH);
+ }
+ @Override
+ public void run() {
+ ISelection selection = this.view.getViewer().getSelection();
+ Object obj = ((IStructuredSelection) selection).getFirstElement();
+ final BugzillaQueryCategory cat = (BugzillaQueryCategory) obj;
+ if (obj instanceof BugzillaQueryCategory) {
+ WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
+ protected void execute(IProgressMonitor monitor) throws CoreException {
+ PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
+ public void run() {
+ cat.refreshBugs();
+ RefreshBugzillaQueryAction.this.view.getViewer().refresh();
+ }
+ });
+ }
+ };
+ // Use the progess service to execute the runnable
+ IProgressService service = PlatformUI.getWorkbench().getProgressService();
+ try {
+ service.run(true, false, op);
+ } catch (InvocationTargetException e) {
+ // Operation was canceled
+ MylarPlugin.log(e, e.getMessage());
+ } catch (InterruptedException e) {
+ // Handle the wrapped exception
+ MylarPlugin.log(e, e.getMessage());
+ }
+ }
+ }
+}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/RefreshBugzillaReportsAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/RefreshBugzillaReportsAction.java
index 794519baf..473d66077 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/RefreshBugzillaReportsAction.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/RefreshBugzillaReportsAction.java
@@ -39,83 +39,75 @@ import org.eclipse.ui.progress.IProgressService;
* @author Mik Kersten and Ken Sueda
*/
public class RefreshBugzillaReportsAction extends Action {
-
+
public static final String ID = "org.eclipse.mylar.tasks.actions.refresh.bugdb";
-
+
private final TaskListView view;
+ private boolean showProgress = true;
+
public RefreshBugzillaReportsAction(TaskListView view) {
this.view = view;
setText("Refresh Bugzilla reports");
- setToolTipText("Refresh Bugzilla reports");
- setId(ID);
- setImageDescriptor(MylarImages.TASK_BUG_REFRESH);
+ setToolTipText("Refresh Bugzilla reports");
+ setId(ID);
+ setImageDescriptor(MylarImages.TASK_BUG_REFRESH);
+ }
+
+ public void setShowProgress(boolean show) {
+ this.showProgress = show;
}
-
- @Override
+
+ @Override
public void run() {
- MylarPlugin.getDefault().actionObserved(this);
+ MylarPlugin.getDefault().actionObserved(this);
// TODO background?
- // perform the update in an operation so that we get a progress monitor
- // update the structure bridge cache with the reference provider cached bugs
- WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
- protected void execute(IProgressMonitor monitor) throws CoreException {
-
- List<ITask> tasks = MylarTasksPlugin.getTaskListManager().getTaskList().getRootTasks();
-
- for (ITask task : tasks) {
- if (task instanceof BugzillaTask) {
- ((BugzillaTask)task).refresh();
- }
+ // perform the update in an operation so that we get a progress monitor
+ // update the structure bridge cache with the reference provider cached
+ // bugs
+ if (showProgress) {
+ runWithProgressBar();
+ } else {
+ refreshTasksAndQueries();
+ }
+ }
+
+ private void runWithProgressBar() {
+ WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
+ protected void execute(IProgressMonitor monitor)
+ throws CoreException {
+
+ refreshTasksAndQueries();
+
+ // clear the caches
+ Set<String> cachedHandles = new HashSet<String>();
+ cachedHandles.addAll(MylarTasksPlugin.getDefault().getStructureBridge().getCachedHandles());
+ cachedHandles.addAll(MylarTasksPlugin.getReferenceProvider().getCachedHandles());
+ MylarTasksPlugin.getDefault().getStructureBridge().clearCache();
+ MylarTasksPlugin.getReferenceProvider().clearCachedReports();
+ BugzillaStructureBridge bridge = MylarTasksPlugin.getDefault().getStructureBridge();
+ monitor.beginTask("Downloading Bugs", cachedHandles.size());
+ for (String key : cachedHandles) {
+ try {
+ String[] parts = key.split(";");
+ final int id = Integer.parseInt(parts[1]);
+ BugReport bug = BugzillaRepository.getInstance().getCurrentBug(id);
+ if (bug != null) {
+ bridge.cache(key, bug);
+ }
+ } catch (Exception e) {
+ }
+
+ monitor.worked(1);
}
- for (AbstractCategory cat : MylarTasksPlugin.getTaskListManager().getTaskList().getCategories()) {
- if (cat instanceof TaskCategory) {
- for (ITask task : ((TaskCategory)cat).getChildren()) {
- if (task instanceof BugzillaTask) {
- ((BugzillaTask)task).refresh();
- }
- }
- RefreshBugzillaReportsAction.this.view.refreshChildren(((TaskCategory)cat).getChildren());
- }
- else if (cat instanceof BugzillaQueryCategory) {
- final BugzillaQueryCategory bqc = (BugzillaQueryCategory) cat;
- PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
-
- public void run() {
- bqc.refreshBugs();
- RefreshBugzillaReportsAction.this.view.getViewer().refresh();
- }
- });
- }
- }
-
- // clear the caches
- Set<String> cachedHandles = new HashSet<String>();
- cachedHandles.addAll(MylarTasksPlugin.getDefault().getStructureBridge().getCachedHandles());
- cachedHandles.addAll(MylarTasksPlugin.getReferenceProvider().getCachedHandles());
- MylarTasksPlugin.getDefault().getStructureBridge().clearCache();
- MylarTasksPlugin.getReferenceProvider().clearCachedReports();
-
- BugzillaStructureBridge bridge = MylarTasksPlugin.getDefault().getStructureBridge();
- monitor.beginTask("Downloading Bugs" , cachedHandles.size());
- for(String key: cachedHandles){
- try {
- String [] parts = key.split(";");
- final int id = Integer.parseInt(parts[1]);
- BugReport bug = BugzillaRepository.getInstance().getCurrentBug(id);
- if(bug != null)
- bridge.cache(key, bug);
- }catch(Exception e){}
-
- monitor.worked(1);
- }
- monitor.done();
- RefreshBugzillaReportsAction.this.view.getViewer().refresh();
- }
- };
-
- // Use the progess service to execute the runnable
- IProgressService service = PlatformUI.getWorkbench().getProgressService();
+ monitor.done();
+ RefreshBugzillaReportsAction.this.view.getViewer().refresh();
+ }
+ };
+
+ // Use the progess service to execute the runnable
+ IProgressService service = PlatformUI.getWorkbench()
+ .getProgressService();
try {
service.run(true, false, op);
} catch (InvocationTargetException e) {
@@ -124,4 +116,35 @@ public class RefreshBugzillaReportsAction extends Action {
// Handle the wrapped exception
}
}
+
+ private void refreshTasksAndQueries() {
+ List<ITask> tasks = MylarTasksPlugin.getTaskListManager().getTaskList().getRootTasks();
+
+ for (ITask task : tasks) {
+ if (task instanceof BugzillaTask) {
+ ((BugzillaTask) task).refresh();
+ }
+ }
+ for (AbstractCategory cat : MylarTasksPlugin
+ .getTaskListManager().getTaskList().getCategories()) {
+ if (cat instanceof TaskCategory) {
+ for (ITask task : ((TaskCategory) cat).getChildren()) {
+ if (task instanceof BugzillaTask) {
+ ((BugzillaTask) task).refresh();
+ }
+ }
+ RefreshBugzillaReportsAction.this.view.refreshChildren(((TaskCategory) cat).getChildren());
+ } else if (cat instanceof BugzillaQueryCategory) {
+ final BugzillaQueryCategory bqc = (BugzillaQueryCategory) cat;
+ PlatformUI.getWorkbench().getDisplay().syncExec(
+ new Runnable() {
+ public void run() {
+ bqc.refreshBugs();
+ RefreshBugzillaReportsAction.this.view.getViewer().refresh();
+ }
+ });
+ }
+ }
+ RefreshBugzillaReportsAction.this.view.getViewer().refresh();
+ }
} \ No newline at end of file
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 f9a0d7125..e87c53b1c 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
@@ -74,6 +74,7 @@ import org.eclipse.mylar.tasks.ui.actions.MarkTaskCompleteAction;
import org.eclipse.mylar.tasks.ui.actions.MarkTaskIncompleteAction;
import org.eclipse.mylar.tasks.ui.actions.MoveTaskToRootAction;
import org.eclipse.mylar.tasks.ui.actions.OpenTaskEditorAction;
+import org.eclipse.mylar.tasks.ui.actions.RefreshBugzillaQueryAction;
import org.eclipse.mylar.tasks.ui.actions.RefreshBugzillaReportsAction;
import org.eclipse.mylar.tasks.ui.actions.TaskActivateAction;
import org.eclipse.mylar.tasks.ui.actions.TaskDeactivateAction;
@@ -145,6 +146,7 @@ public class TaskListView extends ViewPart {
// private FilterIncompleteTasksAction filterInCompleteTask;
private PriorityDropDownAction filterOnPriority;
private Action moveTaskToRoot;
+ private RefreshBugzillaQueryAction refreshQuery;
private PriorityFilter priorityFilter = new PriorityFilter();
protected String[] columnNames = new String[] { "", ".", "!", "Description" };
@@ -685,8 +687,13 @@ public class TaskListView extends ViewPart {
viewer.setSorter(new TaskListTableSorter(columnNames[sortIndex]));
}
viewer.addFilter(priorityFilter);
- if(MylarTasksPlugin.getDefault().isFilterInCompleteMode()) viewer.addFilter(inCompleteFilter);
- if(MylarTasksPlugin.getDefault().isFilterCompleteMode()) viewer.addFilter(completeFilter);
+ if (MylarTasksPlugin.getDefault().isFilterInCompleteMode()) viewer.addFilter(inCompleteFilter);
+ if (MylarTasksPlugin.getDefault().isFilterCompleteMode()) viewer.addFilter(completeFilter);
+ if (MylarTasksPlugin.getDefault().refreshOnStartUpEnabled()) {
+ refresh.setShowProgress(false);
+ refresh.run();
+ refresh.setShowProgress(true);
+ }
viewer.refresh();
}
@@ -915,6 +922,7 @@ public class TaskListView extends ViewPart {
manager.add(delete);
manager.add(clearSelectedTaskscapeAction);
manager.add(moveTaskToRoot);
+ manager.add(refreshQuery);
manager.add(new Separator());
MenuManager subMenuManager = new MenuManager("Choose Highlighter");
final Object selectedObject = ((IStructuredSelection)viewer.getSelection()).getFirstElement();
@@ -961,42 +969,48 @@ public class TaskListView extends ViewPart {
incompleteTask.setEnabled(false);
moveTaskToRoot.setEnabled(false);
delete.setEnabled(false);
+ refreshQuery.setEnabled(false);
} else if(sel instanceof BugzillaTask){
completeTask.setEnabled(false);
incompleteTask.setEnabled(false);
+ refreshQuery.setEnabled(false);
} else if(sel instanceof AbstractCategory){
clearSelectedTaskscapeAction.setEnabled(false);
moveTaskToRoot.setEnabled(false);
completeTask.setEnabled(false);
incompleteTask.setEnabled(false);
+ if (sel instanceof BugzillaQueryCategory) {
+ refreshQuery.setEnabled(true);
+ } else {
+ refreshQuery.setEnabled(false);
+ }
} else {
delete.setEnabled(true);
moveTaskToRoot.setEnabled(true);
completeTask.setEnabled(true);
incompleteTask.setEnabled(true);
clearSelectedTaskscapeAction.setEnabled(true);
- }
-
+ refreshQuery.setEnabled(false);
+ }
}else {
delete.setEnabled(true);
moveTaskToRoot.setEnabled(true);
clearSelectedTaskscapeAction.setEnabled(false);
+ refreshQuery.setEnabled(false);
}
}
private void fillLocalToolBar(IToolBarManager manager) {
- manager.add(createTask);
+ manager.add(createTask);
manager.add(createCategory);
manager.add(new Separator());
- manager.add(createBugzillaTask);
-
+ manager.add(createBugzillaTask);
manager.add(createBugzillaQueryCategory);
manager.add(refresh);
manager.add(new Separator());
manager.add(filterCompleteTask);
// manager.add(filterInCompleteTask);
- manager.add(filterOnPriority);
-
+ manager.add(filterOnPriority);
}
/**
@@ -1018,7 +1032,8 @@ public class TaskListView extends ViewPart {
doubleClickAction = new OpenTaskEditorAction(this);
filterCompleteTask = new FilterCompletedTasksAction(this);
// filterInCompleteTask = new FilterIncompleteTasksAction();
- filterOnPriority = new PriorityDropDownAction();
+ filterOnPriority = new PriorityDropDownAction();
+ refreshQuery = new RefreshBugzillaQueryAction(this);
}
/**

Back to the top