Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkersten2005-08-11 15:28:55 +0000
committermkersten2005-08-11 15:28:55 +0000
commit474bd9a90ae5fa7203430882053b5464e0bfa4b7 (patch)
tree5e8dca79a7706fbe841d3fec7caf7a4024fd4d0d /org.eclipse.mylyn.tasks.ui
parent4745d35e1a310e1f91a58a69bec98686cc6c269a (diff)
downloadorg.eclipse.mylyn.tasks-474bd9a90ae5fa7203430882053b5464e0bfa4b7.tar.gz
org.eclipse.mylyn.tasks-474bd9a90ae5fa7203430882053b5464e0bfa4b7.tar.xz
org.eclipse.mylyn.tasks-474bd9a90ae5fa7203430882053b5464e0bfa4b7.zip
Made task list startup early to ensure it is read
Diffstat (limited to 'org.eclipse.mylyn.tasks.ui')
-rw-r--r--org.eclipse.mylyn.tasks.ui/plugin.xml5
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/MylarTasklistPlugin.java31
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasklist/ui/views/TaskListView.java39
3 files changed, 52 insertions, 23 deletions
diff --git a/org.eclipse.mylyn.tasks.ui/plugin.xml b/org.eclipse.mylyn.tasks.ui/plugin.xml
index b5f6b75d1..367822cbd 100644
--- a/org.eclipse.mylyn.tasks.ui/plugin.xml
+++ b/org.eclipse.mylyn.tasks.ui/plugin.xml
@@ -3,6 +3,11 @@
<plugin>
<extension-point id="taskListContributor" name="TaskList Contributor" schema="schema/taskListContributor.exsd"/>
+ <extension
+ name="Mylar Task List Startup"
+ point="org.eclipse.ui.startup">
+ </extension>
+
<extension
id="org.eclipse.mylar.helpDocs"
name="Mylar Help"
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 79c0602e6..8c64e5724 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
@@ -33,6 +33,7 @@ import org.eclipse.mylar.tasklist.ui.TasksReminderDialog;
import org.eclipse.mylar.tasklist.ui.views.TaskListView;
import org.eclipse.swt.events.ShellEvent;
import org.eclipse.swt.events.ShellListener;
+import org.eclipse.ui.IStartup;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.internal.Workbench;
@@ -42,7 +43,7 @@ import org.osgi.framework.BundleContext;
/**
* @author Mik Kersten
*/
-public class MylarTasklistPlugin extends AbstractUIPlugin {
+public class MylarTasklistPlugin extends AbstractUIPlugin implements IStartup {
private static MylarTasklistPlugin plugin;
private static TaskListManager taskListManager;
@@ -150,7 +151,7 @@ public class MylarTasklistPlugin extends AbstractUIPlugin {
}
}
- private static ITaskActivityListener TASK_LIST_LISTENER = new ITaskActivityListener() {
+ private static ITaskActivityListener CONTEXT_MANAGER_TASK_LISTENER = new ITaskActivityListener() {
public void taskActivated(ITask task) {
MylarPlugin.getContextManager().taskActivated(task.getHandle(), task.getPath());
@@ -264,29 +265,31 @@ public class MylarTasklistPlugin extends AbstractUIPlugin {
public MylarTasklistPlugin() {
super();
plugin = this;
- }
-
- @Override
- public void start(BundleContext context) throws Exception {
initializeDefaultPreferences(getPrefs());
externalizer = new TaskListExternalizer();
String path = MylarPlugin.getDefault().getUserDataDirectory() + File.separator + DEFAULT_TASK_LIST_FILE;
File taskListFile = new File(path);
taskListManager = new TaskListManager(taskListFile);
- taskListManager.addListener(TASK_LIST_LISTENER);
- taskListManager.readTaskList();
- if (taskListManager.getTaskList() == null) taskListManager.createNewTaskList();
-
+ taskListManager.addListener(CONTEXT_MANAGER_TASK_LISTENER);
+ }
+
+ public void earlyStartup() {
final IWorkbench workbench = PlatformUI.getWorkbench();
workbench.getDisplay().asyncExec(new Runnable() {
public void run() {
- Workbench.getInstance().getActiveWorkbenchWindow().getShell().addShellListener(SHELL_LISTENER);
+ taskListManager.readTaskList();
+ if (taskListManager.getTaskList() == null) taskListManager.createNewTaskList();
+
+ Workbench.getInstance().getActiveWorkbenchWindow().getShell().addShellListener(SHELL_LISTENER);
MylarPlugin.getDefault().getPluginPreferences().addPropertyChangeListener(PREFERENCE_LISTENER);
-
}
- });
- super.start(context);
+ });
+ }
+
+ @Override
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
}
@Override
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 f73edb93b..a95159bb6 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
@@ -93,9 +93,11 @@ import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.IViewSite;
+import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.internal.Workbench;
import org.eclipse.ui.internal.dialogs.FilteredTree;
import org.eclipse.ui.part.DrillDownAdapter;
@@ -134,6 +136,8 @@ public class TaskListView extends ViewPart {
private static TaskCompleteFilter COMPLETE_FILTER = new TaskCompleteFilter();
private List<ITaskFilter> filters = new ArrayList<ITaskFilter>();
+ private static final String FILTER_LABEL = "<filter>";
+
protected String[] columnNames = new String[] { "", ".", "!", "Description" };
protected int[] columnWidths = new int[] { 70, 20, 20, 120 };
private TreeColumn[] columns;
@@ -369,15 +373,21 @@ public class TaskListView extends ViewPart {
// };
class TaskListContentProvider implements IStructuredContentProvider, ITreeContentProvider {
- public void inputChanged(Viewer v, Object oldInput, Object newInput) {
+
+ public void inputChanged(Viewer v, Object oldInput, Object newInput) {
// don't care if the input changes
+ expandToActiveTasks();
}
public void dispose() {
// don't care if we are disposed
}
public Object[] getElements(Object parent) {
if (parent.equals(getViewSite())) {
- return applyFilter(MylarTasklistPlugin.getTaskListManager().getTaskList().getRoots()).toArray();
+// if (MylarTasklistPlugin.getTaskListManager() != null) {
+ return applyFilter(MylarTasklistPlugin.getTaskListManager().getTaskList().getRoots()).toArray();
+// } else {
+// return new Object[0];
+// }
// return MylarTasklistPlugin.getTaskListManager().getTaskList().getRoots().toArray();
}
return getChildren(parent);
@@ -441,7 +451,7 @@ public class TaskListView extends ViewPart {
private List<Object> getFilteredChildrenFor(Object parent) {
if (((Text) tree.getFilterControl()).getText() == ""
- || ((Text) tree.getFilterControl()).getText().startsWith("type filter")) {
+ || ((Text) tree.getFilterControl()).getText().startsWith(FILTER_LABEL)) {
List<Object> children = new ArrayList<Object>();
if (parent instanceof AbstractCategory) {
List<? extends ITaskListElement> list = ((AbstractCategory) parent)
@@ -450,7 +460,7 @@ public class TaskListView extends ViewPart {
if (!filter(list.get(i))) {
children.add(list.get(i));
}
- }
+ }
return children;
} else if (parent instanceof Task) {
List<ITask> subTasks = ((Task)parent).getChildren();
@@ -765,7 +775,7 @@ public class TaskListView extends ViewPart {
@Override
public void createPartControl(Composite parent) {
tree = new FilteredTree(parent, SWT.VERTICAL | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.HIDE_SELECTION, new TaskListPatternFilter());
- ((Text)tree.getFilterControl()).setText("<filter>");
+ ((Text)tree.getFilterControl()).setText(FILTER_LABEL);
getViewer().getTree().setHeaderVisible(true);
getViewer().getTree().setLinesVisible(true);
getViewer().setColumnProperties(columnNames);
@@ -922,10 +932,15 @@ public class TaskListView extends ViewPart {
}
private void expandToActiveTasks() {
- List<ITask> activeTasks = MylarTasklistPlugin.getTaskListManager().getTaskList().getActiveTasks();
- for (ITask t : activeTasks) {
- getViewer().expandToLevel(t, 0);
- }
+ final IWorkbench workbench = PlatformUI.getWorkbench();
+ workbench.getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ List<ITask> activeTasks = MylarTasklistPlugin.getTaskListManager().getTaskList().getActiveTasks();
+ for (ITask t : activeTasks) {
+ getViewer().expandToLevel(t, 0);
+ }
+ }
+ });
}
private void hookContextMenu() {
@@ -1184,6 +1199,7 @@ public class TaskListView extends ViewPart {
public void notifyTaskDataChanged(ITask task) {
if (getViewer().getTree() != null && !getViewer().getTree().isDisposed()) {
getViewer().refresh();
+ expandToActiveTasks();
}
}
@@ -1305,6 +1321,11 @@ public class TaskListView extends ViewPart {
// fillLocalToolBar(getViewSite().getActionBars().getToolBarManager());
// getViewSite().getActionBars().getToolBarManager().update(true);
// }
+
+ @Override
+ public void dispose() {
+ super.dispose();
+ }
}
//TextTransfer textTransfer = TextTransfer.getInstance();

Back to the top