diff options
86 files changed, 2086 insertions, 1489 deletions
diff --git a/org.eclipse.mylyn.bugzilla.ui/META-INF/MANIFEST.MF b/org.eclipse.mylyn.bugzilla.ui/META-INF/MANIFEST.MF index 67c3e646e..e0809f1d0 100644 --- a/org.eclipse.mylyn.bugzilla.ui/META-INF/MANIFEST.MF +++ b/org.eclipse.mylyn.bugzilla.ui/META-INF/MANIFEST.MF @@ -10,20 +10,22 @@ Require-Bundle: org.eclipse.ui, org.eclipse.core.runtime, org.eclipse.core.resources, org.eclipse.compare, + org.eclipse.mylar.tasks, org.eclipse.search, org.eclipse.ui.views, org.eclipse.ui.ide, org.eclipse.mylar.bugzilla.core, + org.eclipse.mylar.core, org.eclipse.ui.browser, org.eclipse.ui.forms Eclipse-AutoStart: true Export-Package: org.eclipse.mylar.bugzilla.ui, org.eclipse.mylar.bugzilla.ui.actions, org.eclipse.mylar.bugzilla.ui.editor, - org.eclipse.mylar.bugzilla.ui.favorites, org.eclipse.mylar.bugzilla.ui.favorites.actions, org.eclipse.mylar.bugzilla.ui.outline, org.eclipse.mylar.bugzilla.ui.query, org.eclipse.mylar.bugzilla.ui.search, + org.eclipse.mylar.bugzilla.ui.tasks, org.eclipse.mylar.bugzilla.ui.wizard Bundle-ClassPath: bugzilla-ui.jar diff --git a/org.eclipse.mylyn.bugzilla.ui/plugin.xml b/org.eclipse.mylyn.bugzilla.ui/plugin.xml index 2aee1614d..ecc79aa55 100644 --- a/org.eclipse.mylyn.bugzilla.ui/plugin.xml +++ b/org.eclipse.mylyn.bugzilla.ui/plugin.xml @@ -4,6 +4,11 @@ <plugin> <extension + name="Bugzilla startup" + point="org.eclipse.ui.startup"> + </extension> + + <extension id="org.eclipse.mylar.bugzilla.wizards" name="Bug Wizard" point="org.eclipse.ui.newWizards"> @@ -18,7 +23,7 @@ id="org.eclipse.mylar.bugzilla.bugWizard" name="New Bug Report"> <description> - Create a new bug report + Create a new bug report </description> </wizard> </extension> @@ -63,7 +68,7 @@ id="org.eclipse.mylar.bugzilla.core.search.bugzillaSearchPage" label="Bugzilla Search" tabPosition="999"/> - </extension> + </extension> <extension point="org.eclipse.ui.editors"> <editor @@ -78,6 +83,11 @@ class="org.eclipse.mylar.bugzilla.ui.editor.NewBugEditor" id="org.eclipse.mylar.bugzilla.ui.newBugEditor"> </editor> + <editor + icon="icons/elcl16/bug.gif" + name="Bugzilla task viewer" + class="org.eclipse.mylar.bugzilla.ui.tasks.BugzillaTaskEditor" + id="org.eclipse.mylar.bugzilla.ui.tasks.bugzillaTaskEditor"/> </extension> <extension id="org.eclipse.mylar.bugzilla.help.context" diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/BugzillaUiPlugin.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/BugzillaUiPlugin.java index 37b2b640b..e9980248b 100644 --- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/BugzillaUiPlugin.java +++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/BugzillaUiPlugin.java @@ -2,16 +2,25 @@ package org.eclipse.mylar.bugzilla.ui; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.mylar.bugzilla.core.BugzillaPlugin; +import org.eclipse.mylar.bugzilla.ui.tasks.BugzillaContentProvider; +import org.eclipse.mylar.bugzilla.ui.tasks.BugzillaTaskExternalizer; +import org.eclipse.mylar.bugzilla.ui.tasks.BugzillaTaskListManager; +import org.eclipse.mylar.tasks.MylarTasksPlugin; +import org.eclipse.ui.IStartup; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.PlatformUI; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; /** * The main plugin class to be used in the desktop. */ -public class BugzillaUiPlugin extends AbstractUIPlugin { +public class BugzillaUiPlugin extends AbstractUIPlugin implements IStartup { - //The shared instance. - private static BugzillaUiPlugin plugin; + private BugzillaContentProvider bugzillaProvider; + private BugzillaTaskListManager bugzillaTaskListManager; + private static BugzillaUiPlugin plugin; + /** * The constructor. @@ -20,12 +29,26 @@ public class BugzillaUiPlugin extends AbstractUIPlugin { plugin = this; } + public void earlyStartup() { + final IWorkbench workbench = PlatformUI.getWorkbench(); + workbench.getDisplay().asyncExec(new Runnable() { + public void run() { + BugzillaPlugin.setResultEditorMatchAdapter(new BugzillaResultMatchAdapter()); + bugzillaProvider = new BugzillaContentProvider(); + bugzillaTaskListManager = new BugzillaTaskListManager(); + + MylarTasksPlugin.getDefault().getTaskListExternalizer().addExternalizer( + new BugzillaTaskExternalizer() + ); + } + }); + } + /** * This method is called upon plug-in activation */ public void start(BundleContext context) throws Exception { super.start(context); - BugzillaPlugin.setResultEditorMatchAdapter(new BugzillaResultMatchAdapter()); } /** @@ -53,4 +76,16 @@ public class BugzillaUiPlugin extends AbstractUIPlugin { public static ImageDescriptor getImageDescriptor(String path) { return AbstractUIPlugin.imageDescriptorFromPlugin("org.eclipse.mylar.bugzilla.ui", path); } + + public BugzillaContentProvider getBugzillaProvider() { + return bugzillaProvider; + } + + public void setBugzillaProvider(BugzillaContentProvider bugzillaProvider) { + this.bugzillaProvider = bugzillaProvider; + } + + public BugzillaTaskListManager getBugzillaTaskListManager() { + return bugzillaTaskListManager; + } } diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/CreateBugzillaQueryCategoryAction.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/CreateBugzillaQueryCategoryAction.java index e18fb2346..85808f7fd 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/CreateBugzillaQueryCategoryAction.java +++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/CreateBugzillaQueryCategoryAction.java @@ -9,18 +9,18 @@ * University Of British Columbia - initial API and implementation *******************************************************************************/ -package org.eclipse.mylar.tasks.ui.actions; +package org.eclipse.mylar.bugzilla.ui.actions; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.action.Action; import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.mylar.bugzilla.ui.tasks.BugzillaQueryCategory; +import org.eclipse.mylar.bugzilla.ui.tasks.BugzillaQueryDialog; import org.eclipse.mylar.core.MylarPlugin; -import org.eclipse.mylar.tasks.BugzillaQueryCategory; +import org.eclipse.mylar.tasks.TaskListImages; import org.eclipse.mylar.tasks.MylarTasksPlugin; -import org.eclipse.mylar.tasks.ui.views.BugzillaQueryDialog; import org.eclipse.mylar.tasks.ui.views.TaskListView; -import org.eclipse.mylar.ui.MylarImages; import org.eclipse.swt.widgets.Display; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.actions.WorkspaceModifyOperation; @@ -40,7 +40,7 @@ public class CreateBugzillaQueryCategoryAction extends Action { setText("Add Bugzilla Query"); setToolTipText("Add Bugzilla Query"); setId(ID); - setImageDescriptor(MylarImages.CATEGORY_QUERY_NEW); + setImageDescriptor(TaskListImages.CATEGORY_QUERY_NEW); } @Override diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/CreateBugzillaTaskAction.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/CreateBugzillaTaskAction.java index c1c4fce1e..8bfe181fd 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/CreateBugzillaTaskAction.java +++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/CreateBugzillaTaskAction.java @@ -9,16 +9,17 @@ * University Of British Columbia - initial API and implementation *******************************************************************************/ -package org.eclipse.mylar.tasks.ui.actions; +package org.eclipse.mylar.bugzilla.ui.actions; import org.eclipse.jface.action.Action; import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.mylar.tasks.BugzillaTask; +import org.eclipse.mylar.bugzilla.ui.BugzillaUiPlugin; +import org.eclipse.mylar.bugzilla.ui.tasks.BugzillaTask; import org.eclipse.mylar.tasks.ITask; +import org.eclipse.mylar.tasks.TaskListImages; import org.eclipse.mylar.tasks.MylarTasksPlugin; import org.eclipse.mylar.tasks.TaskCategory; import org.eclipse.mylar.tasks.ui.views.TaskListView; -import org.eclipse.mylar.ui.MylarImages; /** * @author Mik Kersten and Ken Sueda @@ -34,7 +35,7 @@ public class CreateBugzillaTaskAction extends Action { setText("Add Bugzilla Report"); setToolTipText("Add Bugzilla Report"); setId(ID); - setImageDescriptor(MylarImages.TASK_BUGZILLA_NEW); + setImageDescriptor(TaskListImages.TASK_BUGZILLA_NEW); } @Override @@ -64,12 +65,16 @@ public class CreateBugzillaTaskAction extends Action { // return; // } - ITask newTask = new BugzillaTask("Bugzilla-"+bugId, "<bugzilla info>"); + BugzillaTask newBugTask = new BugzillaTask("Bugzilla-"+bugId, "<bugzilla info>"); + BugzillaTask bugTask = BugzillaUiPlugin.getDefault().getBugzillaTaskListManager().getFromBugzillaTaskRegistry(newBugTask.getHandle()); + if(bugTask == null) { + BugzillaUiPlugin.getDefault().getBugzillaTaskListManager().addToBugzillaTaskRegistry((BugzillaTask)bugTask); + } Object selectedObject = ((IStructuredSelection)this.view.getViewer().getSelection()).getFirstElement(); if (selectedObject instanceof TaskCategory){ - ((TaskCategory)selectedObject).addTask(newTask); + ((TaskCategory)selectedObject).addTask((ITask)bugTask); } else { - MylarTasksPlugin.getTaskListManager().getTaskList().addRootTask(newTask); + MylarTasksPlugin.getTaskListManager().getTaskList().addRootTask((ITask)bugTask); } this.view.getViewer().refresh(); } diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/RefreshBugzillaAction.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/RefreshBugzillaAction.java index d1774762e..58fb20f7d 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/RefreshBugzillaAction.java +++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/RefreshBugzillaAction.java @@ -9,7 +9,7 @@ * University Of British Columbia - initial API and implementation *******************************************************************************/ -package org.eclipse.mylar.tasks.ui.actions; +package org.eclipse.mylar.bugzilla.ui.actions; import java.lang.reflect.InvocationTargetException; @@ -18,10 +18,10 @@ 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.bugzilla.ui.tasks.BugzillaQueryCategory; import org.eclipse.mylar.core.MylarPlugin; -import org.eclipse.mylar.tasks.BugzillaQueryCategory; +import org.eclipse.mylar.tasks.TaskListImages; 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; @@ -39,7 +39,7 @@ public class RefreshBugzillaAction extends Action { setText("Bugzilla Rrefresh"); setToolTipText("Bugzilla Refresh"); setId(ID); - setImageDescriptor(MylarImages.TASK_BUG_REFRESH); + setImageDescriptor(TaskListImages.TASK_BUG_REFRESH); } @Override public void run() { diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/RefreshBugzillaReportsAction.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/RefreshBugzillaReportsAction.java index cf2ff428c..ef6dedef0 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/RefreshBugzillaReportsAction.java +++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/actions/RefreshBugzillaReportsAction.java @@ -9,7 +9,7 @@ * University Of British Columbia - initial API and implementation *******************************************************************************/ -package org.eclipse.mylar.tasks.ui.actions; +package org.eclipse.mylar.bugzilla.ui.actions; import java.lang.reflect.InvocationTargetException; import java.util.HashSet; @@ -21,15 +21,14 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.jface.action.Action; import org.eclipse.mylar.bugzilla.core.BugReport; import org.eclipse.mylar.bugzilla.core.BugzillaRepository; +import org.eclipse.mylar.bugzilla.ui.tasks.BugzillaQueryCategory; +import org.eclipse.mylar.bugzilla.ui.tasks.BugzillaTask; import org.eclipse.mylar.tasks.AbstractCategory; -import org.eclipse.mylar.tasks.BugzillaQueryCategory; -import org.eclipse.mylar.tasks.BugzillaTask; import org.eclipse.mylar.tasks.ITask; +import org.eclipse.mylar.tasks.TaskListImages; import org.eclipse.mylar.tasks.MylarTasksPlugin; import org.eclipse.mylar.tasks.TaskCategory; -import org.eclipse.mylar.tasks.bugzilla.BugzillaStructureBridge; 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; @@ -50,7 +49,7 @@ public class RefreshBugzillaReportsAction extends Action { setText("Refresh Bugzilla reports"); setToolTipText("Refresh Bugzilla reports"); setId(ID); - setImageDescriptor(MylarImages.TASK_BUG_REFRESH); + setImageDescriptor(TaskListImages.TASK_BUG_REFRESH); } public void setShowProgress(boolean show) { @@ -80,11 +79,14 @@ public class RefreshBugzillaReportsAction extends Action { // 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(); + + // XXX refactored +// 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 { @@ -92,7 +94,9 @@ public class RefreshBugzillaReportsAction extends Action { final int id = Integer.parseInt(parts[1]); BugReport bug = BugzillaRepository.getInstance().getCurrentBug(id); if (bug != null) { - bridge.cache(key, bug); + // XXX refactored + throw new RuntimeException("unimplemented"); +// bridge.cache(key, bug); } } catch (Exception e) { } diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/search/BugzillaResultCollector.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/search/BugzillaResultCollector.java index 8325771ec..8429dcf2f 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/search/BugzillaResultCollector.java +++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/search/BugzillaResultCollector.java @@ -11,7 +11,7 @@ /* * Created on Oct 4, 2004 */ -package org.eclipse.mylar.tasks.bugzilla.search; +package org.eclipse.mylar.bugzilla.ui.search; import java.text.MessageFormat; import java.util.ArrayList; @@ -141,8 +141,10 @@ public class BugzillaResultCollector implements IBugzillaSearchResultCollector { private String getFormattedMatchesString(int count) { // if only 1 match, return the singular match string String name = ""; - if(operation instanceof BugzillaMylarSearchOperation) - name = " - " + ((BugzillaMylarSearchOperation)operation).getName(); + + // XXX refactored +// if(operation instanceof BugzillaMylarSearchOperation) +// name = " - " + ((BugzillaMylarSearchOperation)operation).getName(); if (count == 1) return MATCH + name; @@ -162,7 +164,7 @@ public class BugzillaResultCollector implements IBugzillaSearchResultCollector { } /** - * Get the number of matches from the operation + * Get the number of matches from the operation * * @return Returns the matchCount. */ diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/BugzillaCacheFile.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaCacheFile.java index 706e9ecf0..6a5fbab0f 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/BugzillaCacheFile.java +++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaCacheFile.java @@ -8,7 +8,7 @@ * Contributors: * University Of British Columbia - initial API and implementation *******************************************************************************/ -package org.eclipse.mylar.tasks.bugzilla; +package org.eclipse.mylar.bugzilla.ui.tasks; import java.io.File; import java.io.FileInputStream; diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/search/BugzillaCategorySearchOperation.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaCategorySearchOperation.java index ea144c0e8..b27c5c498 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/search/BugzillaCategorySearchOperation.java +++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaCategorySearchOperation.java @@ -11,7 +11,7 @@ /* * Created on Oct 14, 2004 */ -package org.eclipse.mylar.tasks.bugzilla.search; +package org.eclipse.mylar.bugzilla.ui.tasks; import java.util.ArrayList; import java.util.List; @@ -24,6 +24,7 @@ import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.mylar.bugzilla.core.search.BugzillaSearchEngine; import org.eclipse.mylar.bugzilla.core.search.BugzillaSearchQuery; import org.eclipse.mylar.bugzilla.core.search.IBugzillaSearchOperation; +import org.eclipse.mylar.bugzilla.ui.search.BugzillaResultCollector; import org.eclipse.mylar.core.MylarPlugin; import org.eclipse.ui.actions.WorkspaceModifyOperation; diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/BugzillaContentProvider.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaContentProvider.java index 83af0e16c..2f5bf4cc7 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/BugzillaContentProvider.java +++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaContentProvider.java @@ -11,10 +11,9 @@ /* * Created on Jan 13, 2005 */ -package org.eclipse.mylar.tasks.bugzilla; +package org.eclipse.mylar.bugzilla.ui.tasks; import org.eclipse.mylar.bugzilla.core.BugReport; -import org.eclipse.mylar.tasks.BugzillaTask; /** diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/BugzillaHit.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaHit.java index 2e7a28de4..d68ea337b 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/BugzillaHit.java +++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaHit.java @@ -9,11 +9,12 @@ * University Of British Columbia - initial API and implementation *******************************************************************************/ -package org.eclipse.mylar.tasks; +package org.eclipse.mylar.bugzilla.ui.tasks; -import org.eclipse.mylar.bugzilla.core.BugzillaImages; import org.eclipse.mylar.bugzilla.core.BugzillaRepository; -import org.eclipse.mylar.ui.MylarImages; +import org.eclipse.mylar.bugzilla.ui.BugzillaImages; +import org.eclipse.mylar.tasks.ITaskListElement; +import org.eclipse.mylar.tasks.TaskListImages; import org.eclipse.swt.graphics.Image; /** @@ -57,7 +58,7 @@ public class BugzillaHit implements ITaskListElement { if (isTask()) { return task.getStatusIcon(); } else { - return MylarImages.getImage(MylarImages.TASK_INACTIVE); + return TaskListImages.getImage(TaskListImages.TASK_INACTIVE); } } diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/BugzillaQueryCategory.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaQueryCategory.java index 7a7259a0e..f8b43d478 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/BugzillaQueryCategory.java +++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaQueryCategory.java @@ -9,7 +9,7 @@ * University Of British Columbia - initial API and implementation *******************************************************************************/ -package org.eclipse.mylar.tasks; +package org.eclipse.mylar.bugzilla.ui.tasks; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -25,10 +25,11 @@ import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.mylar.bugzilla.core.BugzillaPlugin; import org.eclipse.mylar.bugzilla.core.IBugzillaConstants; import org.eclipse.mylar.bugzilla.core.search.BugzillaSearchHit; -import org.eclipse.mylar.tasks.bugzilla.search.BugzillaCategorySearchOperation; -import org.eclipse.mylar.tasks.bugzilla.search.BugzillaResultCollector; -import org.eclipse.mylar.tasks.bugzilla.search.BugzillaCategorySearchOperation.ICategorySearchListener; -import org.eclipse.mylar.ui.MylarImages; +import org.eclipse.mylar.bugzilla.ui.BugzillaUiPlugin; +import org.eclipse.mylar.bugzilla.ui.search.BugzillaResultCollector; +import org.eclipse.mylar.bugzilla.ui.tasks.BugzillaCategorySearchOperation.ICategorySearchListener; +import org.eclipse.mylar.tasks.AbstractCategory; +import org.eclipse.mylar.tasks.TaskListImages; import org.eclipse.swt.graphics.Image; import org.eclipse.ui.PlatformUI; @@ -42,8 +43,7 @@ public class BugzillaQueryCategory extends AbstractCategory { private List<BugzillaHit> hits = new ArrayList<BugzillaHit>(); private boolean hasBeenRefreshed = false; - public class BugzillaQueryCategorySearchListener implements - ICategorySearchListener { + public class BugzillaQueryCategorySearchListener implements ICategorySearchListener { Map<Integer, BugzillaSearchHit> hits = new HashMap<Integer, BugzillaSearchHit>(); @@ -76,7 +76,7 @@ public class BugzillaQueryCategory extends AbstractCategory { public Image getIcon() { - return MylarImages.getImage(MylarImages.CATEGORY_QUERY); + return TaskListImages.getImage(TaskListImages.CATEGORY_QUERY); } public String getUrl() { @@ -88,7 +88,7 @@ public class BugzillaQueryCategory extends AbstractCategory { } public void addHit(BugzillaHit hit) { - BugzillaTask task = MylarTasksPlugin.getTaskListManager().getTaskList().getFromBugzillaTaskRegistry(hit.getHandle()); + BugzillaTask task = BugzillaUiPlugin.getDefault().getBugzillaTaskListManager().getFromBugzillaTaskRegistry(hit.getHandle()); hit.setAssociatedTask(task); hits.add(hit); } diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/views/BugzillaQueryDialog.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaQueryDialog.java index 54c56ca5c..ff2e1cbb5 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/views/BugzillaQueryDialog.java +++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaQueryDialog.java @@ -8,7 +8,7 @@ * Contributors: * University Of British Columbia - initial API and implementation *******************************************************************************/ -package org.eclipse.mylar.tasks.ui.views; +package org.eclipse.mylar.bugzilla.ui.tasks; import java.io.UnsupportedEncodingException; diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/BugzillaReportNode.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaReportNode.java index 9552f5f21..5adcaa8aa 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/BugzillaReportNode.java +++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaReportNode.java @@ -8,10 +8,8 @@ * Contributors: * University Of British Columbia - initial API and implementation *******************************************************************************/ -/* - * Created on Oct 21, 2004 - */ -package org.eclipse.mylar.tasks.bugzilla; + +package org.eclipse.mylar.bugzilla.ui.tasks; import java.io.IOException; import java.net.MalformedURLException; diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/BugzillaTask.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaTask.java index f0fac7247..17497787f 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/BugzillaTask.java +++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaTask.java @@ -11,7 +11,7 @@ /* * Created on 14-Jan-2005 */ -package org.eclipse.mylar.tasks; +package org.eclipse.mylar.bugzilla.ui.tasks; import java.io.IOException; import java.util.ArrayList; @@ -33,10 +33,12 @@ import org.eclipse.mylar.bugzilla.core.BugzillaPlugin; import org.eclipse.mylar.bugzilla.core.BugzillaRepository; import org.eclipse.mylar.bugzilla.core.IBugzillaBug; import org.eclipse.mylar.bugzilla.core.offline.OfflineReportsFile; +import org.eclipse.mylar.bugzilla.ui.BugzillaUiPlugin; import org.eclipse.mylar.bugzilla.ui.OfflineView; import org.eclipse.mylar.core.MylarPlugin; -import org.eclipse.mylar.tasks.ui.BugzillaTaskEditorInput; -import org.eclipse.mylar.ui.MylarImages; +import org.eclipse.mylar.tasks.TaskListImages; +import org.eclipse.mylar.tasks.MylarTasksPlugin; +import org.eclipse.mylar.tasks.Task; import org.eclipse.swt.graphics.Image; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IWorkbench; @@ -107,7 +109,7 @@ public class BugzillaTask extends Task { @Override public String getLabel() { - return MylarTasksPlugin.getDefault().getBugzillaProvider().getBugzillaDescription(this); + return BugzillaUiPlugin.getDefault().getBugzillaProvider().getBugzillaDescription(this); } /** @@ -481,10 +483,18 @@ public class BugzillaTask extends Task { } public Image getIcon() { - return MylarImages.getImage(MylarImages.TASK_BUGZILLA); + return TaskListImages.getImage(TaskListImages.TASK_BUGZILLA); } public String getBugUrl() { return BugzillaRepository.getBugUrl(getBugId(handle)); } + + public boolean canEditDescription() { + return false; + } + + public String getDeleteConfirmationMessage() { + return "Remove this report from the task list, and discard any task context or local notes?"; + } } diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/BugzillaTaskEditor.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaTaskEditor.java index 66de9939e..950a7766d 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/BugzillaTaskEditor.java +++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaTaskEditor.java @@ -11,7 +11,7 @@ /* * Created on 31-Jan-2005 */ -package org.eclipse.mylar.tasks.ui; +package org.eclipse.mylar.bugzilla.ui.tasks; import org.eclipse.core.resources.IMarker; import org.eclipse.core.runtime.IProgressMonitor; @@ -22,10 +22,11 @@ import org.eclipse.mylar.bugzilla.ui.editor.AbstractBugEditor; import org.eclipse.mylar.bugzilla.ui.editor.ExistingBugEditor; import org.eclipse.mylar.bugzilla.ui.editor.ExistingBugEditorInput; import org.eclipse.mylar.core.MylarPlugin; -import org.eclipse.mylar.tasks.BugzillaTask; +import org.eclipse.mylar.tasks.TaskListImages; import org.eclipse.mylar.tasks.MylarTasksPlugin; +import org.eclipse.mylar.tasks.ui.TaskEditorInput; +import org.eclipse.mylar.tasks.ui.TaskSummaryEditor; import org.eclipse.mylar.tasks.ui.views.TaskListView; -import org.eclipse.mylar.ui.MylarImages; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.ui.IEditorInput; @@ -170,7 +171,7 @@ public class BugzillaTaskEditor extends MultiPageEditorPart { // Set the title on the editor's tab this.setPartName("Bug #" + bugzillaEditorInput.getBugId()); - this.setTitleImage(MylarImages.getImage(MylarImages.TASK_BUGZILLA)); + this.setTitleImage(TaskListImages.getImage(TaskListImages.TASK_BUGZILLA)); } @Override diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/BugzillaTaskEditorInput.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaTaskEditorInput.java index af9e7f5e9..4a4b0aba9 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/BugzillaTaskEditorInput.java +++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaTaskEditorInput.java @@ -11,7 +11,7 @@ /* * Created on 1-Feb-2005 */ -package org.eclipse.mylar.tasks.ui; +package org.eclipse.mylar.bugzilla.ui.tasks; import java.io.IOException; @@ -20,7 +20,6 @@ import javax.security.auth.login.LoginException; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.mylar.bugzilla.core.BugReport; import org.eclipse.mylar.bugzilla.ui.editor.ExistingBugEditorInput; -import org.eclipse.mylar.tasks.BugzillaTask; import org.eclipse.ui.IPersistableElement; diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaTaskExternalizer.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaTaskExternalizer.java new file mode 100644 index 000000000..4db885c95 --- /dev/null +++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaTaskExternalizer.java @@ -0,0 +1,130 @@ +/******************************************************************************* + * 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.bugzilla.ui.tasks; + +import java.util.Date; +import java.util.List; + +import org.eclipse.mylar.bugzilla.ui.tasks.BugzillaTask.BugTaskState; +import org.eclipse.mylar.core.MylarPlugin; +import org.eclipse.mylar.tasks.AbstractCategory; +import org.eclipse.mylar.tasks.ITask; +import org.eclipse.mylar.tasks.Task; +import org.eclipse.mylar.tasks.TaskCategory; +import org.eclipse.mylar.tasks.TaskList; +import org.eclipse.mylar.tasks.util.DefaultTaskListExternalizer; +import org.eclipse.mylar.tasks.util.ITaskListExternalizer; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +/** + * @author Mik Kersten and Ken Sueda + */ +public class BugzillaTaskExternalizer extends DefaultTaskListExternalizer { + + private static final String BUGZILLA = "Bugzilla"; + private static final String LAST_DATE = "LastDate"; + private static final String DIRTY = "Dirty"; + private static final String URL = "URL"; + private static final String DESCRIPTION = "Description"; + + private static final String TAG_BUGZILLA_CATEGORY = "BugzillaQuery" + TAG_CATEGORY; + private static final String TAG_TASK = "BugzillaReport"; + + @Override + public boolean canReadCategory(Node node) { + return node.getNodeName().equals(getCategoryTagName()); + } + + @Override + public void readCategory(Node node, TaskList tlist) { + Element e = (Element) node; + BugzillaQueryCategory cat = new BugzillaQueryCategory(e.getAttribute(DESCRIPTION), e.getAttribute(URL)); + tlist.addCategory(cat); + } + + public boolean canCreateElementFor(AbstractCategory category) { + return category instanceof BugzillaQueryCategory; + } + + public Element createCategoryElement(AbstractCategory category, Document doc, Element parent) { + BugzillaQueryCategory queryCategory = (BugzillaQueryCategory)category; + Element node = doc.createElement(getCategoryTagName()); + node.setAttribute(DESCRIPTION, queryCategory.getDescription(false)); + node.setAttribute(URL, queryCategory.getUrl()); + parent.appendChild(node); + return node; + } + + public boolean canCreateElementFor(ITask task) { + return task instanceof BugzillaTask; + } + + public Element createTaskElement(ITask task, Document doc, Element parent) { + Element node = super.createTaskElement(task, doc, parent); + BugzillaTask bt = (BugzillaTask) task; + node.setAttribute(BUGZILLA, TRUE); + if (bt.getLastRefresh() != null) { + node.setAttribute(LAST_DATE, new Long(bt.getLastRefreshTime() + .getTime()).toString()); + } else { + node.setAttribute(LAST_DATE, new Long(new Date().getTime()).toString()); + } + + if (bt.isDirty()) { + node.setAttribute(DIRTY, TRUE); + } else { + node.setAttribute(DIRTY, FALSE); + } + bt.saveBugReport(false); + return node; + } + + @Override + public boolean canReadTask(Node node) { + return node.getNodeName().equals(getTaskTagName()); + } + + @Override + public ITask readTask(Node node, TaskList tlist, AbstractCategory category, ITask parent) { + Element element = (Element) node; + String handle = element.getAttribute(HANDLE); + String label = element.getAttribute(LABEL); + BugzillaTask task = new BugzillaTask(handle, label, true); + readTaskInfo(task, tlist, element, category, parent); + + task.setState(BugTaskState.FREE); + task.setLastRefresh(new Date(new Long(element.getAttribute("LastDate")) + .longValue())); + if (element.getAttribute("Dirty").compareTo("true") == 0) { + task.setDirty(true); + } else { + task.setDirty(false); + } + if (task.readBugReport() == false) { + MylarPlugin.log("Failed to read bug report", null); + } + return task; + } + + @Override + public String getCategoryTagName() { + return TAG_BUGZILLA_CATEGORY; + } + + @Override + public String getTaskTagName() { + return TAG_TASK; + } +} diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaTaskListManager.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaTaskListManager.java new file mode 100644 index 000000000..353d2804c --- /dev/null +++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/BugzillaTaskListManager.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * 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.bugzilla.ui.tasks; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author Mik Kersten and Ken Sueda + */ +public class BugzillaTaskListManager { + + private Map<String, BugzillaTask> bugzillaTaskRegistry = new HashMap<String, BugzillaTask>(); + + // XXX we never delete anything from this registry + + public void addToBugzillaTaskRegistry(BugzillaTask task){ + if(bugzillaTaskRegistry.get(task.getHandle()) == null){ + bugzillaTaskRegistry.put(task.getHandle(), task); + } + } + + public BugzillaTask getFromBugzillaTaskRegistry(String handle){ + return bugzillaTaskRegistry.get(handle); + } + + public Map<String, BugzillaTask> getBugzillaTaskRegistry(){ + return bugzillaTaskRegistry; + } + +} diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/StackTrace.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/StackTrace.java index 096c0c732..617599738 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/StackTrace.java +++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/StackTrace.java @@ -8,10 +8,8 @@ * Contributors: * University Of British Columbia - initial API and implementation *******************************************************************************/ -/* - * Created on Dec 8, 2004 - */ -package org.eclipse.mylar.tasks.bugzilla; + +package org.eclipse.mylar.bugzilla.ui.tasks; import java.util.ArrayList; import java.util.List; diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/TaskListActionContributor.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/TaskListActionContributor.java new file mode 100644 index 000000000..e5afdcb54 --- /dev/null +++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/bugzilla/ui/tasks/TaskListActionContributor.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * 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.bugzilla.ui.tasks; + +import org.eclipse.mylar.bugzilla.ui.actions.CreateBugzillaQueryCategoryAction; +import org.eclipse.mylar.bugzilla.ui.actions.CreateBugzillaTaskAction; +import org.eclipse.mylar.bugzilla.ui.actions.RefreshBugzillaAction; +import org.eclipse.mylar.bugzilla.ui.actions.RefreshBugzillaReportsAction; +import org.eclipse.mylar.tasks.ui.views.TaskListView; + +/** + * @author Mik Kersten and Ken Sueda + */ +public class TaskListActionContributor { + + private RefreshBugzillaReportsAction refresh; + private CreateBugzillaQueryCategoryAction createBugzillaQueryCategory; + private CreateBugzillaTaskAction createBugzillaTask; + private RefreshBugzillaAction refreshQuery; + + public TaskListActionContributor(TaskListView view) { + refresh = new RefreshBugzillaReportsAction(view); + createBugzillaQueryCategory = new CreateBugzillaQueryCategoryAction(view); + createBugzillaTask = new CreateBugzillaTaskAction(view); + refreshQuery = new RefreshBugzillaAction(view); + } + +} diff --git a/org.eclipse.mylyn.tasks.core/.classpath b/org.eclipse.mylyn.tasks.core/.classpath new file mode 100644 index 000000000..751c8f2e5 --- /dev/null +++ b/org.eclipse.mylyn.tasks.core/.classpath @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" path="src"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/org.eclipse.mylyn.tasks.core/.cvsignore b/org.eclipse.mylyn.tasks.core/.cvsignore new file mode 100644 index 000000000..ba077a403 --- /dev/null +++ b/org.eclipse.mylyn.tasks.core/.cvsignore @@ -0,0 +1 @@ +bin diff --git a/org.eclipse.mylyn.tasks.core/.project b/org.eclipse.mylyn.tasks.core/.project new file mode 100644 index 000000000..d9ab28171 --- /dev/null +++ b/org.eclipse.mylyn.tasks.core/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.mylar.bugzilla</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/org.eclipse.mylyn.tasks.core/META-INF/MANIFEST.MF b/org.eclipse.mylyn.tasks.core/META-INF/MANIFEST.MF new file mode 100644 index 000000000..ae5939677 --- /dev/null +++ b/org.eclipse.mylyn.tasks.core/META-INF/MANIFEST.MF @@ -0,0 +1,20 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Mylar Bugzilla Plug-in +Bundle-SymbolicName: org.eclipse.mylar.bugzilla;singleton:=true +Bundle-Version: 0.3.1 +Bundle-Activator: org.eclipse.mylar.bugzilla.MylarBugzillaPlugin +Bundle-Localization: plugin +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + org.eclipse.mylar.core, + org.eclipse.mylar.ui, + org.eclipse.mylar.bugzilla.ui, + org.eclipse.mylar.bugzilla.core, + org.eclipse.jdt.core, + org.eclipse.ui.ide, + org.eclipse.core.resources, + org.eclipse.mylar.tasks +Eclipse-AutoStart: true +Export-Package: org.eclipse.mylar.bugzilla, + org.eclipse.mylar.tasks.search diff --git a/org.eclipse.mylyn.tasks.core/build.properties b/org.eclipse.mylyn.tasks.core/build.properties new file mode 100644 index 000000000..34d2e4d2d --- /dev/null +++ b/org.eclipse.mylyn.tasks.core/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/org.eclipse.mylyn.tasks.core/plugin.xml b/org.eclipse.mylyn.tasks.core/plugin.xml new file mode 100644 index 000000000..e593c5e63 --- /dev/null +++ b/org.eclipse.mylyn.tasks.core/plugin.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.0"?> +<?eclipse version="3.0"?> +<plugin> + <extension + name="Mylar Bugzilla startup" + point="org.eclipse.ui.startup"> + </extension> +</plugin> diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/BugzillaEditingMonitor.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugzilla/BugzillaEditingMonitor.java index 8eadb4e55..3bee8b160 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/BugzillaEditingMonitor.java +++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugzilla/BugzillaEditingMonitor.java @@ -11,14 +11,14 @@ /* * Created on Apr 27, 2005 */ -package org.eclipse.mylar.tasks.bugzilla; +package org.eclipse.mylar.bugzilla; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.mylar.bugzilla.ui.editor.AbstractBugEditor; import org.eclipse.mylar.bugzilla.ui.outline.BugzillaReportSelection; +import org.eclipse.mylar.bugzilla.ui.tasks.BugzillaTaskEditor; import org.eclipse.mylar.core.AbstractSelectionMonitor; -import org.eclipse.mylar.tasks.ui.BugzillaTaskEditor; import org.eclipse.ui.IWorkbenchPart; diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/BugzillaMylarBridge.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugzilla/BugzillaMylarBridge.java index 6dc4033b9..38325ab31 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/BugzillaMylarBridge.java +++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugzilla/BugzillaMylarBridge.java @@ -11,7 +11,7 @@ /* * Created on Oct 1, 2004 */ -package org.eclipse.mylar.tasks.bugzilla; +package org.eclipse.mylar.bugzilla; import java.util.HashMap; import java.util.List; @@ -20,6 +20,7 @@ import java.util.Map; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IMember; +import org.eclipse.mylar.bugzilla.ui.tasks.BugzillaReportNode; /** diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/ui/BugzillaNodeLabelProvider.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugzilla/BugzillaNodeLabelProvider.java index 01a2f5791..b43781a00 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/ui/BugzillaNodeLabelProvider.java +++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugzilla/BugzillaNodeLabelProvider.java @@ -11,14 +11,13 @@ /* * Created on Apr 18, 2005 */ -package org.eclipse.mylar.tasks.bugzilla.ui; +package org.eclipse.mylar.bugzilla; import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.jface.viewers.ILabelProviderListener; import org.eclipse.mylar.bugzilla.core.BugReport; +import org.eclipse.mylar.bugzilla.ui.tasks.BugzillaReportNode; import org.eclipse.mylar.core.model.ITaskscapeNode; -import org.eclipse.mylar.tasks.MylarTasksPlugin; -import org.eclipse.mylar.tasks.bugzilla.BugzillaReportNode; import org.eclipse.mylar.ui.MylarImages; import org.eclipse.swt.graphics.Image; @@ -39,14 +38,14 @@ public class BugzillaNodeLabelProvider implements ILabelProvider { // try to get from the cache before downloading Object report; - BugzillaReportNode reportNode = MylarTasksPlugin.getReferenceProvider().getCached(node.getElementHandle()); - BugReport cachedReport = MylarTasksPlugin.getDefault().getStructureBridge().getCached(node.getElementHandle()); + BugzillaReportNode reportNode = MylarBugzillaPlugin.getReferenceProvider().getCached(node.getElementHandle()); + BugReport cachedReport = MylarBugzillaPlugin.getDefault().getStructureBridge().getCached(node.getElementHandle()); if(reportNode != null && cachedReport == null){ report = reportNode; } else{ - report = MylarTasksPlugin.getDefault().getStructureBridge().getObjectForHandle(node.getElementHandle()); + report = MylarBugzillaPlugin.getDefault().getStructureBridge().getObjectForHandle(node.getElementHandle()); } - return MylarTasksPlugin.getDefault().getStructureBridge().getName(report); + return MylarBugzillaPlugin.getDefault().getStructureBridge().getName(report); } public void addListener(ILabelProviderListener listener) { diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/BugzillaStructureBridge.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugzilla/BugzillaStructureBridge.java index 9301c8135..3d49edeaf 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/BugzillaStructureBridge.java +++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugzilla/BugzillaStructureBridge.java @@ -11,7 +11,7 @@ /* * Created on May 2, 2005 */ -package org.eclipse.mylar.tasks.bugzilla; +package org.eclipse.mylar.bugzilla; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; @@ -32,9 +32,10 @@ import org.eclipse.mylar.bugzilla.core.search.BugzillaSearchHit; import org.eclipse.mylar.bugzilla.ui.editor.AbstractBugEditor; import org.eclipse.mylar.bugzilla.ui.outline.BugzillaOutlineNode; import org.eclipse.mylar.bugzilla.ui.outline.BugzillaReportSelection; +import org.eclipse.mylar.bugzilla.ui.tasks.BugzillaCacheFile; +import org.eclipse.mylar.bugzilla.ui.tasks.BugzillaReportNode; import org.eclipse.mylar.core.IMylarStructureBridge; import org.eclipse.mylar.core.MylarPlugin; -import org.eclipse.mylar.tasks.MylarTasksPlugin; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.actions.WorkspaceModifyOperation; @@ -252,7 +253,7 @@ public class BugzillaStructureBridge implements IMylarStructureBridge { private BugzillaCacheFile cacheFile; private IPath getCacheFile() { - IPath stateLocation = Platform.getPluginStateLocation(MylarTasksPlugin.getDefault()); + IPath stateLocation = Platform.getPluginStateLocation(MylarBugzillaPlugin.getDefault()); IPath configFile = stateLocation.append("offlineReports"); return configFile; } diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/ui/BugzillaUiBridge.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugzilla/BugzillaUiBridge.java index 406566baa..9a340df45 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/ui/BugzillaUiBridge.java +++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugzilla/BugzillaUiBridge.java @@ -11,7 +11,7 @@ /* * Created on Apr 6, 2005 */ -package org.eclipse.mylar.tasks.bugzilla.ui; +package org.eclipse.mylar.bugzilla; import java.util.ArrayList; import java.util.Collections; @@ -24,12 +24,12 @@ import org.eclipse.mylar.bugzilla.ui.BugzillaOpenStructure; import org.eclipse.mylar.bugzilla.ui.ViewBugzillaAction; import org.eclipse.mylar.bugzilla.ui.editor.AbstractBugEditor; import org.eclipse.mylar.bugzilla.ui.outline.BugzillaOutlinePage; +import org.eclipse.mylar.bugzilla.ui.tasks.BugzillaTask; +import org.eclipse.mylar.bugzilla.ui.tasks.BugzillaTaskEditor; import org.eclipse.mylar.core.model.ITaskscapeNode; -import org.eclipse.mylar.tasks.BugzillaTask; import org.eclipse.mylar.tasks.ITask; import org.eclipse.mylar.tasks.MylarTasksPlugin; -import org.eclipse.mylar.tasks.bugzilla.BugzillaReferencesProvider; -import org.eclipse.mylar.tasks.ui.BugzillaTaskEditor; +import org.eclipse.mylar.tasks.search.BugzillaReferencesProvider; import org.eclipse.mylar.ui.IMylarUiBridge; import org.eclipse.mylar.ui.MylarImages; import org.eclipse.ui.IEditorPart; diff --git a/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugzilla/MylarBugzillaPlugin.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugzilla/MylarBugzillaPlugin.java new file mode 100644 index 000000000..6bcf64076 --- /dev/null +++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/bugzilla/MylarBugzillaPlugin.java @@ -0,0 +1,100 @@ +package org.eclipse.mylar.bugzilla; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.mylar.core.MylarPlugin; +import org.eclipse.mylar.tasks.search.BugzillaReferencesProvider; +import org.eclipse.mylar.ui.MylarUiPlugin; +import org.eclipse.ui.IStartup; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.internal.Workbench; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The main plugin class to be used in the desktop. + */ +public class MylarBugzillaPlugin extends AbstractUIPlugin implements IStartup { + + private static BugzillaMylarBridge bridge = null; + private static BugzillaReferencesProvider referencesProvider = new BugzillaReferencesProvider(); + private BugzillaStructureBridge structureBridge; + + private static MylarBugzillaPlugin plugin; + + public MylarBugzillaPlugin() { + plugin = this; + } + + public void earlyStartup() { + final IWorkbench workbench = PlatformUI.getWorkbench(); + workbench.getDisplay().asyncExec(new Runnable() { + public void run() { + structureBridge = new BugzillaStructureBridge(); + + MylarPlugin.getDefault().addBridge(structureBridge); + MylarPlugin.getTaskscapeManager().addListener(referencesProvider); + MylarUiPlugin.getDefault().addAdapter(BugzillaStructureBridge.EXTENSION, new BugzillaUiBridge()); + MylarPlugin.getDefault().getSelectionMonitors().add(new BugzillaEditingMonitor()); + + IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); + if (window != null) { + // create a new bridge and initialize it + bridge = new BugzillaMylarBridge(); + } + } + }); + } + + /** + * This method is called upon plug-in activation + */ + public void start(BundleContext context) throws Exception { + super.start(context); + } + + /** + * This method is called when the plug-in is stopped + */ + public void stop(BundleContext context) throws Exception { + super.stop(context); + plugin = null; + } + + /** + * Returns the shared instance. + */ + public static MylarBugzillaPlugin getDefault() { + return plugin; + } + + /** + * Returns an image descriptor for the image file at the given + * plug-in relative path. + * + * @param path the path + * @return the image descriptor + */ + public static ImageDescriptor getImageDescriptor(String path) { + return AbstractUIPlugin.imageDescriptorFromPlugin("org.eclipse.mylar.bugzilla.bridge", path); + } + + public static BugzillaMylarBridge getBridge() { + // make sure that the bridge initialized, if not, make a new one + if (bridge == null) { + bridge = new BugzillaMylarBridge(); + } + return bridge; + } + + + public BugzillaStructureBridge getStructureBridge() { + return structureBridge; + } + + public static BugzillaReferencesProvider getReferenceProvider() { + return referencesProvider; + + } +} diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/search/BugzillaMylarSearch.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/search/BugzillaMylarSearch.java index dea6339ee..0abfd8126 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/search/BugzillaMylarSearch.java +++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/search/BugzillaMylarSearch.java @@ -11,9 +11,10 @@ /* * Created on Oct 13, 2004 */ -package org.eclipse.mylar.tasks.bugzilla.search; +package org.eclipse.mylar.tasks.search; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import org.eclipse.core.runtime.IProgressMonitor; @@ -22,11 +23,11 @@ import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IMember; +import org.eclipse.mylar.bugzilla.BugzillaMylarBridge; +import org.eclipse.mylar.bugzilla.ui.tasks.BugzillaReportNode; +import org.eclipse.mylar.core.model.InterestComparator; import org.eclipse.mylar.core.search.IActiveSearchListener; import org.eclipse.mylar.core.search.IMylarSearchOperation; -import org.eclipse.mylar.tasks.bugzilla.BugzillaMylarBridge; -import org.eclipse.mylar.tasks.bugzilla.BugzillaReportNode; -import org.eclipse.mylar.tasks.bugzilla.Util; /** @@ -66,7 +67,7 @@ public class BugzillaMylarSearch implements IMylarSearchOperation { // perform the bugzilla search // get only the useful landmarks (IMember) - List<IMember> members = Util.getMemberLandmarks(landmarks); + List<IMember> members = getMemberLandmarks(landmarks); // go through all of the landmarks that we are given and perform a // search on them @@ -145,4 +146,29 @@ public class BugzillaMylarSearch implements IMylarSearchOperation { } } + /** + * Get only the landmarks that are IMember and sort them according to their + * DOI value (highest to lowest) + * + * @param landmarks + * The landmarks to check + * @return List of IMember landmarks sorted by DOI value + */ + public static List<IMember> getMemberLandmarks(List<IJavaElement> landmarks) { + List<IMember> memberLandmarks = new ArrayList<IMember>(); + + for(IJavaElement je : landmarks) { + + // keep only the IMember landmarks + if (je instanceof IMember) { + memberLandmarks.add((IMember)je); + } + } + + // sort the landmarks + Collections.sort(memberLandmarks, new InterestComparator<IMember>()); + + return memberLandmarks; + } + }
\ No newline at end of file diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/search/BugzillaMylarSearchJob.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/search/BugzillaMylarSearchJob.java index d6900c5c2..b596f5536 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/search/BugzillaMylarSearchJob.java +++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/search/BugzillaMylarSearchJob.java @@ -11,7 +11,7 @@ /* * Created on Oct 6, 2004 */ -package org.eclipse.mylar.tasks.bugzilla.search; +package org.eclipse.mylar.tasks.search; import javax.security.auth.login.LoginException; @@ -21,9 +21,9 @@ import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.mylar.bugzilla.BugzillaMylarBridge; import org.eclipse.mylar.bugzilla.core.BugzillaPlugin; import org.eclipse.mylar.bugzilla.core.IBugzillaConstants; -import org.eclipse.mylar.tasks.bugzilla.BugzillaMylarBridge; import org.eclipse.ui.PlatformUI; diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/search/BugzillaMylarSearchOperation.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/search/BugzillaMylarSearchOperation.java index 4ab4e16c5..d679c8bdd 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/search/BugzillaMylarSearchOperation.java +++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/search/BugzillaMylarSearchOperation.java @@ -11,7 +11,7 @@ /* * Created on Oct 14, 2004 */ -package org.eclipse.mylar.tasks.bugzilla.search; +package org.eclipse.mylar.tasks.search; import java.util.ArrayList; import java.util.Iterator; @@ -27,20 +27,21 @@ import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IMember; import org.eclipse.jdt.core.IType; import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.mylar.bugzilla.MylarBugzillaPlugin; import org.eclipse.mylar.bugzilla.core.BugReport; import org.eclipse.mylar.bugzilla.core.Comment; import org.eclipse.mylar.bugzilla.core.search.BugzillaSearchEngine; import org.eclipse.mylar.bugzilla.core.search.BugzillaSearchHit; import org.eclipse.mylar.bugzilla.core.search.BugzillaSearchQuery; import org.eclipse.mylar.bugzilla.core.search.IBugzillaSearchOperation; +import org.eclipse.mylar.bugzilla.ui.search.BugzillaResultCollector; +import org.eclipse.mylar.bugzilla.ui.tasks.BugzillaReportNode; +import org.eclipse.mylar.bugzilla.ui.tasks.BugzillaTask; +import org.eclipse.mylar.bugzilla.ui.tasks.StackTrace; import org.eclipse.mylar.core.MylarPlugin; -import org.eclipse.mylar.tasks.BugzillaTask; import org.eclipse.mylar.tasks.ITask; -import org.eclipse.mylar.tasks.TaskCategory; import org.eclipse.mylar.tasks.MylarTasksPlugin; -import org.eclipse.mylar.tasks.bugzilla.BugzillaReportNode; -import org.eclipse.mylar.tasks.bugzilla.StackTrace; -import org.eclipse.mylar.tasks.bugzilla.Util; +import org.eclipse.mylar.tasks.TaskCategory; import org.eclipse.ui.actions.WorkspaceModifyOperation; @@ -133,8 +134,7 @@ public class BugzillaMylarSearchOperation extends WorkspaceModifyOperation // we completed the search, so notify all of the listeners // that the search has been completed - MylarTasksPlugin.getBridge() - .addToLandmarksHash(doiList, javaElement, scope); + MylarBugzillaPlugin.getBridge().addToLandmarksHash(doiList, javaElement, scope); search.notifySearchCompleted( doiList); // MIK: commmented out logging diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/BugzillaReferencesProvider.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/search/BugzillaReferencesProvider.java index 6b810f142..7212b8995 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/BugzillaReferencesProvider.java +++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/search/BugzillaReferencesProvider.java @@ -11,7 +11,7 @@ /* * Created on Feb 2, 2005 */ -package org.eclipse.mylar.tasks.bugzilla; +package org.eclipse.mylar.tasks.search; import java.util.Collection; import java.util.HashMap; @@ -24,12 +24,13 @@ import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IMember; import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.JavaCore; +import org.eclipse.mylar.bugzilla.BugzillaStructureBridge; +import org.eclipse.mylar.bugzilla.MylarBugzillaPlugin; +import org.eclipse.mylar.bugzilla.ui.tasks.BugzillaReportNode; import org.eclipse.mylar.core.model.ITaskscapeNode; import org.eclipse.mylar.core.search.IActiveSearchListener; import org.eclipse.mylar.core.search.IMylarSearchOperation; import org.eclipse.mylar.core.search.RelationshipProvider; -import org.eclipse.mylar.tasks.MylarTasksPlugin; -import org.eclipse.mylar.tasks.bugzilla.search.BugzillaMylarSearch; /** @@ -80,7 +81,7 @@ public class BugzillaReferencesProvider extends RelationshipProvider { public void searchCompleted(List<?> nodes) { Iterator<?> itr = nodes.iterator(); - BugzillaStructureBridge bridge = MylarTasksPlugin.getDefault().getStructureBridge(); + BugzillaStructureBridge bridge = MylarBugzillaPlugin.getDefault().getStructureBridge(); while(itr.hasNext()) { Object o = itr.next(); diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/Util.java b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/search/Util.java index 1eb287c9c..d883e90ea 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/bugzilla/Util.java +++ b/org.eclipse.mylyn.tasks.core/src/org/eclipse/mylyn/tasks/search/Util.java @@ -11,24 +11,18 @@ /* * Created on Nov 19, 2004 */ -package org.eclipse.mylar.tasks.bugzilla; +package org.eclipse.mylar.tasks.search; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.nio.charset.Charset; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IMember; import org.eclipse.jdt.core.IType; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.mylar.bugzilla.core.BugzillaPlugin; import org.eclipse.mylar.bugzilla.core.BugzillaPreferences; import org.eclipse.mylar.bugzilla.core.IBugzillaConstants; -import org.eclipse.mylar.core.model.InterestComparator; -import org.eclipse.mylar.tasks.bugzilla.search.BugzillaMylarSearchOperation; /** @@ -56,31 +50,6 @@ public class Util { private static String[] statusValues = BugzillaPreferences.queryOptionsToArray(prefs.getString(IBugzillaConstants.STATUS_VALUES)); /** - * Get only the landmarks that are IMember and sort them according to their - * DOI value (highest to lowest) - * - * @param landmarks - * The landmarks to check - * @return List of IMember landmarks sorted by DOI value - */ - public static List<IMember> getMemberLandmarks(List<IJavaElement> landmarks) { - List<IMember> memberLandmarks = new ArrayList<IMember>(); - - for(IJavaElement je : landmarks) { - - // keep only the IMember landmarks - if (je instanceof IMember) { - memberLandmarks.add((IMember)je); - } - } - - // sort the landmarks - Collections.sort(memberLandmarks, new InterestComparator<IMember>()); - - return memberLandmarks; - } - - /** * Get the bugzilla url used for searching for exact matches * * @param je diff --git a/org.eclipse.mylyn.tasks.tests/META-INF/MANIFEST.MF b/org.eclipse.mylyn.tasks.tests/META-INF/MANIFEST.MF index 6bf658d25..b71f68108 100644 --- a/org.eclipse.mylyn.tasks.tests/META-INF/MANIFEST.MF +++ b/org.eclipse.mylyn.tasks.tests/META-INF/MANIFEST.MF @@ -14,7 +14,9 @@ Require-Bundle: org.eclipse.core.runtime, org.eclipse.jdt.core, org.eclipse.core.resources, org.eclipse.ui, - org.eclipse.mylar.bugzilla.core + org.eclipse.mylar.bugzilla.core, + org.eclipse.mylar.bugzilla.ui, + org.eclipse.mylar.bugzilla Eclipse-AutoStart: true Bundle-ClassPath: mylar-tasklist-tests.jar Export-Package: org.eclipse.mylar.tasks.bugzilla.tests, diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/bugzilla/tests/BugzillaSearchPluginTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/bugzilla/tests/BugzillaSearchPluginTest.java index 566486648..9eec2c3a6 100644 --- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/bugzilla/tests/BugzillaSearchPluginTest.java +++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/bugzilla/tests/BugzillaSearchPluginTest.java @@ -20,16 +20,17 @@ import junit.framework.TestCase; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.IType; +import org.eclipse.mylar.bugzilla.MylarBugzillaPlugin; +import org.eclipse.mylar.bugzilla.ui.tasks.BugzillaReportNode; +import org.eclipse.mylar.bugzilla.ui.tasks.BugzillaTask; +import org.eclipse.mylar.bugzilla.ui.tasks.BugzillaTask.BugTaskState; import org.eclipse.mylar.core.search.IActiveSearchListener; import org.eclipse.mylar.core.tests.support.WorkspaceSetupHelper; import org.eclipse.mylar.core.tests.support.search.SearchPluginTestHelper; -import org.eclipse.mylar.tasks.BugzillaTask; -import org.eclipse.mylar.tasks.TaskCategory; import org.eclipse.mylar.tasks.MylarTasksPlugin; +import org.eclipse.mylar.tasks.TaskCategory; import org.eclipse.mylar.tasks.TaskList; -import org.eclipse.mylar.tasks.BugzillaTask.BugTaskState; -import org.eclipse.mylar.tasks.bugzilla.BugzillaReportNode; -import org.eclipse.mylar.tasks.bugzilla.search.BugzillaMylarSearch; +import org.eclipse.mylar.tasks.search.BugzillaMylarSearch; /*TEST CASES TO HANDLE * 1. what is here @@ -126,7 +127,7 @@ public class BugzillaSearchPluginTest extends TestCase{ // display the time it took for the search // System.err.println("Search Took About " + time + " seconds"); - MylarTasksPlugin.getBridge().removeFromLandmarksHash(astNodeType); + MylarBugzillaPlugin.getBridge().removeFromLandmarksHash(astNodeType); } /** @@ -162,7 +163,7 @@ public class BugzillaSearchPluginTest extends TestCase{ // display the time it took for the search and the results returned // System.err.println("Search Took About " + time + " seconds"); // System.err.println(c); - MylarTasksPlugin.getBridge().removeFromLandmarksHash(astNodeType); + MylarBugzillaPlugin.getBridge().removeFromLandmarksHash(astNodeType); } @@ -199,12 +200,12 @@ public class BugzillaSearchPluginTest extends TestCase{ assertTrue("Results not the right size", c.size() > 0); // TODO should be assertEquals on expected size // check that the search has been saved - List<BugzillaReportNode> saved = MylarTasksPlugin.getBridge().getFromLandmarksHash(astNodeType, BugzillaMylarSearch.UNQUAL); + List<BugzillaReportNode> saved = MylarBugzillaPlugin.getBridge().getFromLandmarksHash(astNodeType, BugzillaMylarSearch.UNQUAL); assertTrue("Results not cached", saved != null); assertTrue("Results not the right size", saved.size() > 0); // TODO should be assertEquals on expected size assertTrue(c.containsAll(saved) && saved.containsAll(c)); - MylarTasksPlugin.getBridge().removeFromLandmarksHash(astNodeType); + MylarBugzillaPlugin.getBridge().removeFromLandmarksHash(astNodeType); } public void testLocalBugUnqual() throws InterruptedException { @@ -263,7 +264,7 @@ public class BugzillaSearchPluginTest extends TestCase{ List<?> c = lists.get(0); assertEquals("Results not the right size", 3, c.size()); - MylarTasksPlugin.getBridge().removeFromLandmarksHash(astNodeType); + MylarBugzillaPlugin.getBridge().removeFromLandmarksHash(astNodeType); MylarTasksPlugin.getTaskListManager().getTaskList().deleteCategory(cat); } @@ -321,7 +322,7 @@ public class BugzillaSearchPluginTest extends TestCase{ List<?> c = lists.get(0); assertEquals("Results not the right size", 1, c.size()); - MylarTasksPlugin.getBridge().removeFromLandmarksHash(astNodeType); + MylarBugzillaPlugin.getBridge().removeFromLandmarksHash(astNodeType); MylarTasksPlugin.getTaskListManager().getTaskList().deleteCategory(cat); } diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/bugzilla/tests/BugzillaStackTraceTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/bugzilla/tests/BugzillaStackTraceTest.java index 9c029cc7e..d8d5f1f81 100644 --- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/bugzilla/tests/BugzillaStackTraceTest.java +++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/bugzilla/tests/BugzillaStackTraceTest.java @@ -22,11 +22,11 @@ import junit.framework.TestCase; import org.eclipse.core.runtime.Path; import org.eclipse.mylar.bugzilla.core.internal.BugParser; import org.eclipse.mylar.bugzilla.core.search.BugzillaSearchHit; +import org.eclipse.mylar.bugzilla.ui.tasks.BugzillaReportNode; +import org.eclipse.mylar.bugzilla.ui.tasks.StackTrace; import org.eclipse.mylar.core.tests.MylarCoreTestsPlugin; import org.eclipse.mylar.core.tests.support.FileTool; -import org.eclipse.mylar.tasks.bugzilla.BugzillaReportNode; -import org.eclipse.mylar.tasks.bugzilla.StackTrace; -import org.eclipse.mylar.tasks.bugzilla.search.BugzillaMylarSearchOperation; +import org.eclipse.mylar.tasks.search.BugzillaMylarSearchOperation; /** diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListManagerTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListManagerTest.java index 7d5babeaa..5f866779a 100644 --- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListManagerTest.java +++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListManagerTest.java @@ -69,8 +69,8 @@ public class TaskListManagerTest extends TestCase { manager.setTaskList(list); manager.readTaskList(); assertNotNull(manager.getTaskList()); - assertEquals(manager.getTaskList().getRootTasks().size(), 2); - assertEquals(manager.getTaskList().getCategories().size(), 2); + assertEquals(2, manager.getTaskList().getRootTasks().size()); + assertEquals(2, manager.getTaskList().getCategories().size()); check(manager); } diff --git a/org.eclipse.mylyn.tasks.ui/META-INF/MANIFEST.MF b/org.eclipse.mylyn.tasks.ui/META-INF/MANIFEST.MF index 876d5c37d..cfa825a52 100644 --- a/org.eclipse.mylyn.tasks.ui/META-INF/MANIFEST.MF +++ b/org.eclipse.mylyn.tasks.ui/META-INF/MANIFEST.MF @@ -17,18 +17,13 @@ Require-Bundle: org.eclipse.ui, org.eclipse.jdt.ui, org.eclipse.pde.ui, org.eclipse.mylar.core, - org.eclipse.mylar.ui, - org.eclipse.jdt.core, - org.eclipse.mylar.bugzilla.core, - org.eclipse.mylar.bugzilla.ui + org.eclipse.jdt.core Eclipse-AutoStart: true Bundle-Vendor: University of British Columbia Bundle-ClassPath: mylar-tasklist.jar Export-Package: org.eclipse.mylar.tasks, - org.eclipse.mylar.tasks.bugzilla, - org.eclipse.mylar.tasks.bugzilla.search, - org.eclipse.mylar.tasks.bugzilla.ui, org.eclipse.mylar.tasks.ui, org.eclipse.mylar.tasks.ui.actions, + org.eclipse.mylar.tasks.ui.preferences, org.eclipse.mylar.tasks.ui.views, org.eclipse.mylar.tasks.util diff --git a/org.eclipse.mylyn.tasks.ui/icons/elcl16/filter-complete.gif b/org.eclipse.mylyn.tasks.ui/icons/elcl16/filter-complete.gif Binary files differnew file mode 100644 index 000000000..13ac9f725 --- /dev/null +++ b/org.eclipse.mylyn.tasks.ui/icons/elcl16/filter-complete.gif diff --git a/org.eclipse.mylyn.tasks.ui/icons/elcl16/filter-priority.gif b/org.eclipse.mylyn.tasks.ui/icons/elcl16/filter-priority.gif Binary files differnew file mode 100644 index 000000000..55816a55a --- /dev/null +++ b/org.eclipse.mylyn.tasks.ui/icons/elcl16/filter-priority.gif diff --git a/org.eclipse.mylyn.tasks.ui/icons/etool16/category-new.gif b/org.eclipse.mylyn.tasks.ui/icons/etool16/category-new.gif Binary files differnew file mode 100644 index 000000000..d3f43d977 --- /dev/null +++ b/org.eclipse.mylyn.tasks.ui/icons/etool16/category-new.gif diff --git a/org.eclipse.mylyn.tasks.ui/icons/etool16/category-query-new.gif b/org.eclipse.mylyn.tasks.ui/icons/etool16/category-query-new.gif Binary files differnew file mode 100644 index 000000000..09fcacad3 --- /dev/null +++ b/org.eclipse.mylyn.tasks.ui/icons/etool16/category-query-new.gif diff --git a/org.eclipse.mylyn.tasks.ui/icons/etool16/category-query.gif b/org.eclipse.mylyn.tasks.ui/icons/etool16/category-query.gif Binary files differnew file mode 100644 index 000000000..94e7d5d1c --- /dev/null +++ b/org.eclipse.mylyn.tasks.ui/icons/etool16/category-query.gif diff --git a/org.eclipse.mylyn.tasks.ui/icons/etool16/category.gif b/org.eclipse.mylyn.tasks.ui/icons/etool16/category.gif Binary files differnew file mode 100644 index 000000000..7efb86ec1 --- /dev/null +++ b/org.eclipse.mylyn.tasks.ui/icons/etool16/category.gif diff --git a/org.eclipse.mylyn.tasks.ui/icons/etool16/color-palette.gif b/org.eclipse.mylyn.tasks.ui/icons/etool16/color-palette.gif Binary files differnew file mode 100644 index 000000000..4c9452786 --- /dev/null +++ b/org.eclipse.mylyn.tasks.ui/icons/etool16/color-palette.gif diff --git a/org.eclipse.mylyn.tasks.ui/icons/etool16/task-active.gif b/org.eclipse.mylyn.tasks.ui/icons/etool16/task-active.gif Binary files differnew file mode 100644 index 000000000..758e83e64 --- /dev/null +++ b/org.eclipse.mylyn.tasks.ui/icons/etool16/task-active.gif diff --git a/org.eclipse.mylyn.tasks.ui/icons/etool16/task-bug-new.gif b/org.eclipse.mylyn.tasks.ui/icons/etool16/task-bug-new.gif Binary files differnew file mode 100644 index 000000000..04f3028c2 --- /dev/null +++ b/org.eclipse.mylyn.tasks.ui/icons/etool16/task-bug-new.gif diff --git a/org.eclipse.mylyn.tasks.ui/icons/etool16/task-bug-refresh.gif b/org.eclipse.mylyn.tasks.ui/icons/etool16/task-bug-refresh.gif Binary files differnew file mode 100644 index 000000000..bb8538b39 --- /dev/null +++ b/org.eclipse.mylyn.tasks.ui/icons/etool16/task-bug-refresh.gif diff --git a/org.eclipse.mylyn.tasks.ui/icons/etool16/task-bug.gif b/org.eclipse.mylyn.tasks.ui/icons/etool16/task-bug.gif Binary files differnew file mode 100644 index 000000000..f2d2f3762 --- /dev/null +++ b/org.eclipse.mylyn.tasks.ui/icons/etool16/task-bug.gif diff --git a/org.eclipse.mylyn.tasks.ui/icons/etool16/task-complete.gif b/org.eclipse.mylyn.tasks.ui/icons/etool16/task-complete.gif Binary files differnew file mode 100644 index 000000000..9cacb96dc --- /dev/null +++ b/org.eclipse.mylyn.tasks.ui/icons/etool16/task-complete.gif diff --git a/org.eclipse.mylyn.tasks.ui/icons/etool16/task-inactive.gif b/org.eclipse.mylyn.tasks.ui/icons/etool16/task-inactive.gif Binary files differnew file mode 100644 index 000000000..443eab400 --- /dev/null +++ b/org.eclipse.mylyn.tasks.ui/icons/etool16/task-inactive.gif diff --git a/org.eclipse.mylyn.tasks.ui/icons/etool16/task-incomplete.gif b/org.eclipse.mylyn.tasks.ui/icons/etool16/task-incomplete.gif Binary files differnew file mode 100644 index 000000000..f6b9f8a59 --- /dev/null +++ b/org.eclipse.mylyn.tasks.ui/icons/etool16/task-incomplete.gif diff --git a/org.eclipse.mylyn.tasks.ui/icons/etool16/task-new.gif b/org.eclipse.mylyn.tasks.ui/icons/etool16/task-new.gif Binary files differnew file mode 100644 index 000000000..8ce54634b --- /dev/null +++ b/org.eclipse.mylyn.tasks.ui/icons/etool16/task-new.gif diff --git a/org.eclipse.mylyn.tasks.ui/icons/etool16/task.gif b/org.eclipse.mylyn.tasks.ui/icons/etool16/task.gif Binary files differnew file mode 100644 index 000000000..9881d3872 --- /dev/null +++ b/org.eclipse.mylyn.tasks.ui/icons/etool16/task.gif diff --git a/org.eclipse.mylyn.tasks.ui/plugin.xml b/org.eclipse.mylyn.tasks.ui/plugin.xml index bf7a1eedf..35d52a32b 100644 --- a/org.eclipse.mylyn.tasks.ui/plugin.xml +++ b/org.eclipse.mylyn.tasks.ui/plugin.xml @@ -2,11 +2,12 @@ <?eclipse version="3.0"?> <plugin> +<!-- <extension name="Mylar Tasks startup" point="org.eclipse.ui.startup"> </extension> - +--> <extension point="org.eclipse.ui.views"> <view name="Mylar Task List" @@ -22,11 +23,6 @@ class="org.eclipse.mylar.tasks.ui.TaskEditor" name="Task Viewer" id="org.eclipse.mylar.tasks.ui.taskEditor"/> - <editor - icon="icons/eview16/task-bug.gif" - name="Bugzilla task viewer" - class="org.eclipse.mylar.tasks.ui.BugzillaTaskEditor" - id="org.eclipse.mylar.tasks.ui.bugzillaTaskEditor"/> </extension> <extension point="org.eclipse.ui.commands"> diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ITask.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ITask.java index 91ba7e260..7a19b201c 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ITask.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ITask.java @@ -85,6 +85,10 @@ public interface ITask extends Serializable { public abstract String getPriority(); + public abstract boolean canEditDescription(); + + public abstract String getDeleteConfirmationMessage(); + public abstract void setPriority(String priority); @Deprecated public abstract boolean isCategory(); 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 0c4cdb164..a51dae414 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 @@ -19,18 +19,13 @@ 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; -import org.eclipse.mylar.tasks.bugzilla.BugzillaMylarBridge; -import org.eclipse.mylar.tasks.bugzilla.BugzillaReferencesProvider; -import org.eclipse.mylar.tasks.bugzilla.BugzillaStructureBridge; -import org.eclipse.mylar.tasks.bugzilla.ui.BugzillaUiBridge; -import org.eclipse.mylar.ui.MylarUiPlugin; +import org.eclipse.mylar.tasks.util.TaskListExternalizer; +import org.eclipse.swt.SWT; import org.eclipse.swt.events.ShellEvent; import org.eclipse.swt.events.ShellListener; +import org.eclipse.swt.graphics.Font; import org.eclipse.ui.IStartup; import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.internal.Workbench; import org.eclipse.ui.plugin.AbstractUIPlugin; @@ -39,11 +34,15 @@ import org.osgi.framework.BundleContext; /** * @author Mik Kersten */ -public class MylarTasksPlugin extends AbstractUIPlugin implements IStartup { +public class MylarTasksPlugin extends AbstractUIPlugin { private static MylarTasksPlugin plugin; private static TaskListManager taskListManager; - private BugzillaContentProvider bugzillaProvider; + private TaskListExternalizer externalizer; + + // TODO: remove hard-coded fonts + public static final Font BOLD = new Font(null, "Tahoma", 8, SWT.BOLD); + public static final Font ITALIC = new Font(null, "Tahoma", 8, SWT.ITALIC); public static final String REFRESH_QUERIES = "org.eclipse.mylar.tasks.queries.refresh"; public static final String REPORT_OPEN_EDITOR = "org.eclipse.mylar.tasks.report.open.editor"; @@ -94,12 +93,7 @@ public class MylarTasksPlugin extends AbstractUIPlugin implements IStartup { } } - /** The bridge between Bugzilla and mylar */ - private static BugzillaMylarBridge bridge = null; - private BugzillaStructureBridge structureBridge; - - private static BugzillaReferencesProvider referencesProvider = new BugzillaReferencesProvider(); private static ITaskActivityListener TASK_LIST_LISTENER = new ITaskActivityListener() { @@ -158,7 +152,7 @@ public class MylarTasksPlugin extends AbstractUIPlugin implements IStartup { getTaskListManager().updateTaskscapeReference(prevDir); String path = MylarPlugin.getDefault().getUserDataDirectory() + File.separator + DEFAULT_TASK_LIST_FILE; - getTaskListManager().setFile(new File(path)); + getTaskListManager().setTaskListFile(new File(path)); } } else { } @@ -168,43 +162,40 @@ public class MylarTasksPlugin extends AbstractUIPlugin implements IStartup { public MylarTasksPlugin() { super(); plugin = this; - initializeDefaultPreferences(getPrefs()); } - - public void earlyStartup() { - final IWorkbench workbench = PlatformUI.getWorkbench(); - workbench.getDisplay().asyncExec(new Runnable() { - public void run() { - - structureBridge = new BugzillaStructureBridge(); - - MylarPlugin.getDefault().addBridge(structureBridge); - MylarPlugin.getTaskscapeManager().addListener(referencesProvider); - MylarUiPlugin.getDefault().addAdapter(BugzillaStructureBridge.EXTENSION, new BugzillaUiBridge()); - MylarPlugin.getDefault().getSelectionMonitors().add(new BugzillaEditingMonitor()); - - IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); - - Workbench.getInstance().getActiveWorkbenchWindow().getShell().addShellListener(SHELL_LISTENER); - MylarPlugin.getDefault().getPluginPreferences().addPropertyChangeListener(PREFERENCE_LISTENER); - - if (window != null) { - // create a new bridge and initialize it - bridge = new BugzillaMylarBridge(); - } - } - }); - } +// /** +// * TODO: consider making a non early startup plug-in +// */ +// public void earlyStartup() { +// final IWorkbench workbench = PlatformUI.getWorkbench(); +// workbench.getDisplay().asyncExec(new Runnable() { +// public void run() { +// +// } +// }); +// } + @Override public void start(BundleContext context) throws Exception { - bugzillaProvider = new BugzillaContentProvider(); + 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(); + + final IWorkbench workbench = PlatformUI.getWorkbench(); + workbench.getDisplay().asyncExec(new Runnable() { + public void run() { + Workbench.getInstance().getActiveWorkbenchWindow().getShell().addShellListener(SHELL_LISTENER); + MylarPlugin.getDefault().getPluginPreferences().addPropertyChangeListener(PREFERENCE_LISTENER); + + } + }); super.start(context); } @@ -225,19 +216,7 @@ public class MylarTasksPlugin extends AbstractUIPlugin implements IStartup { store.setDefault(REPORT_OPEN_INTERNAL, true); store.setDefault(REPORT_OPEN_EXTERNAL, false); } - /** - * Get the bridge for this plugin - * - * @return The bugzilla mylar bridge - */ - public static BugzillaMylarBridge getBridge() { - // make sure that the bridge initialized, if not, make a new one - if (bridge == null) { - bridge = new BugzillaMylarBridge(); - } - return bridge; - } - + public static TaskListManager getTaskListManager() { return taskListManager; @@ -275,23 +254,6 @@ public class MylarTasksPlugin extends AbstractUIPlugin implements IStartup { } return resourceBundle; } - - public BugzillaContentProvider getBugzillaProvider() { - return bugzillaProvider; - } - - public void setBugzillaProvider(BugzillaContentProvider bugzillaProvider) { - this.bugzillaProvider = bugzillaProvider; - } - - public BugzillaStructureBridge getStructureBridge() { - return structureBridge; - } - - public static BugzillaReferencesProvider getReferenceProvider() { - return referencesProvider; - - } public static IPreferenceStore getPrefs() { return MylarPlugin.getDefault().getPreferenceStore(); @@ -345,4 +307,8 @@ public class MylarTasksPlugin extends AbstractUIPlugin implements IStartup { return Report_Open_Mode.EXTERNAL_BROWSER; } } + + public TaskListExternalizer getTaskListExternalizer() { + return externalizer; + } } diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/Task.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/Task.java index 79c4e3692..a2a0a0d26 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/Task.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/Task.java @@ -20,7 +20,6 @@ import java.util.List; import org.eclipse.mylar.core.MylarPlugin; import org.eclipse.mylar.tasks.ui.TaskEditorInput; import org.eclipse.mylar.tasks.ui.views.TaskListView; -import org.eclipse.mylar.ui.MylarImages; import org.eclipse.swt.graphics.Image; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IWorkbenchPage; @@ -175,6 +174,8 @@ public class Task implements ITask, ITaskListElement { /** * Refreshes the tasklist viewer. + * + * TODO: shouldn't be coupled to the TaskListView */ public void notifyTaskDataChange() { final Task task = this; @@ -305,7 +306,7 @@ public class Task implements ITask, ITaskListElement { } public Image getIcon() { - return MylarImages.getImage(MylarImages.TASK); + return TaskListImages.getImage(TaskListImages.TASK); } public String getDescription(boolean label) { @@ -314,9 +315,9 @@ public class Task implements ITask, ITaskListElement { public Image getStatusIcon() { if (isActive()) { - return MylarImages.getImage(MylarImages.TASK_ACTIVE); + return TaskListImages.getImage(TaskListImages.TASK_ACTIVE); } else { - return MylarImages.getImage(MylarImages.TASK_INACTIVE); + return TaskListImages.getImage(TaskListImages.TASK_INACTIVE); } } @@ -376,4 +377,12 @@ public class Task implements ITask, ITaskListElement { return sec; } } + + public boolean canEditDescription() { + return true; + } + + public String getDeleteConfirmationMessage() { + return "Delete the selected task and discard task context?"; + } } diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskCategory.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskCategory.java index 50f69f9c1..a21d259fc 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskCategory.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskCategory.java @@ -17,7 +17,6 @@ import java.io.Serializable; import java.util.ArrayList; import java.util.List; -import org.eclipse.mylar.ui.MylarImages; import org.eclipse.swt.graphics.Image; @@ -35,7 +34,7 @@ public class TaskCategory extends AbstractCategory implements Serializable { } public Image getIcon() { - return MylarImages.getImage(MylarImages.CATEGORY); + return TaskListImages.getImage(TaskListImages.CATEGORY); } @@ -50,16 +49,7 @@ public class TaskCategory extends AbstractCategory implements Serializable { } public void addTask(ITask task) { - if(task instanceof BugzillaTask){ - BugzillaTask bugTask = MylarTasksPlugin.getTaskListManager().getTaskList().getFromBugzillaTaskRegistry(task.getHandle()); - if(bugTask == null){ - MylarTasksPlugin.getTaskListManager().getTaskList().addToBugzillaTaskRegistry((BugzillaTask)task); - } else { - task = bugTask; - } - } tasks.add(task); - } public void removeTask(ITask task) { diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskList.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskList.java index 538712413..604d9050c 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskList.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskList.java @@ -15,9 +15,7 @@ package org.eclipse.mylar.tasks; import java.io.Serializable; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; /** @@ -31,35 +29,19 @@ public class TaskList implements Serializable { private List<AbstractCategory> categories = new ArrayList<AbstractCategory>(); private transient List<ITask> activeTasks = new ArrayList<ITask>(); - // XXX we never delete anything from this registry - private Map<String, BugzillaTask> bugzillaTaskRegistry = new HashMap<String, BugzillaTask>(); - - public void addToBugzillaTaskRegistry(BugzillaTask task){ - if(bugzillaTaskRegistry.get(task.getHandle()) == null){ - bugzillaTaskRegistry.put(task.getHandle(), task); - } - } - - public BugzillaTask getFromBugzillaTaskRegistry(String handle){ - return bugzillaTaskRegistry.get(handle); - } - - public Map<String, BugzillaTask> getBugzillaTaskRegistry(){ - return bugzillaTaskRegistry; - } - public void addRootTask(ITask task) { - if(task instanceof BugzillaTask){ - BugzillaTask bugTask = bugzillaTaskRegistry.get(task.getHandle()); - if(bugTask == null){ - bugzillaTaskRegistry.put(task.getHandle(), (BugzillaTask)task); - rootTasks.add(task); - } else { - rootTasks.add(bugTask); - } - } else { + // XXX refactored +// if(task instanceof BugzillaTask){ +// BugzillaTask bugTask = bugzillaTaskRegistry.get(task.getHandle()); +// if(bugTask == null){ +// bugzillaTaskRegistry.put(task.getHandle(), (BugzillaTask)task); +// rootTasks.add(task); +// } else { +// rootTasks.add(bugTask); +// } +// } else { rootTasks.add(task); - } +// } } public void addCategory(AbstractCategory cat) { @@ -76,9 +58,10 @@ public class TaskList implements Serializable { } public void deleteTask(ITask task) { - if (task instanceof BugzillaTask) { - ((BugzillaTask)task).removeReport(); - } + // XXX refactored +// if (task instanceof BugzillaTask) { +// ((BugzillaTask)task).removeReport(); +// } boolean deleted = deleteTaskHelper(rootTasks, task); if (!deleted) { for (TaskCategory cat : getTaskCategories()) { @@ -157,11 +140,12 @@ public class TaskList implements Serializable { int ihandle = 0; int max = 0; for (ITask t : tasks) { - if (t instanceof BugzillaTask) { - ihandle = 0; - } else { + // XXX refactored +// if (t instanceof BugzillaTask) { +// ihandle = 0; +// } else { ihandle = Integer.parseInt(t.getHandle().substring(t.getHandle().indexOf('-')+1, t.getHandle().length())); - } +// } max = Math.max(ihandle, max); ihandle = largestTaskHandleHelper(t.getChildren()); max = Math.max(ihandle, max); diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskListImages.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskListImages.java new file mode 100644 index 000000000..2f91b0bcc --- /dev/null +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskListImages.java @@ -0,0 +1,87 @@ +/******************************************************************************* + * 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 + *******************************************************************************/ +/* + * Created on Apr 20, 2004 + */ +package org.eclipse.mylar.tasks; + +import java.net.MalformedURLException; +import java.net.URL; +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.swt.graphics.Image; + +/** + * @author Mik Kersten + */ +public class TaskListImages { + + private static Map<ImageDescriptor, Image> imageMap = new HashMap<ImageDescriptor, Image>(); + + private static final String T_ELCL = "elcl16"; + private static final String T_TOOL = "etool16"; + private static final URL baseURL = MylarTasksPlugin.getDefault().getBundle().getEntry("/icons/"); + + public static final ImageDescriptor REMOVE = create(T_ELCL, "remove.gif"); + public static final ImageDescriptor ERASE_TASKSCAPE = create(T_ELCL, "context-clear.gif"); + + public static final ImageDescriptor FILTER_COMPLETE = create(T_ELCL, "filter-complete.gif"); + public static final ImageDescriptor FILTER_PRIORITY = create(T_ELCL, "filter-priority.gif"); + + public static final ImageDescriptor COLOR_PALETTE = create(T_ELCL, "color-palette.gif"); + public static final ImageDescriptor BUG = create(T_ELCL, "bug.gif"); + + public static final ImageDescriptor TASK_BUGZILLA = create(T_TOOL, "task-bug.gif"); + public static final ImageDescriptor TASK_BUGZILLA_NEW = create(T_TOOL, "task-bug-new.gif"); + public static final ImageDescriptor TASK = create(T_TOOL, "task.gif"); + public static final ImageDescriptor TASK_NEW = create(T_TOOL, "task-new.gif"); + public static final ImageDescriptor CATEGORY = create(T_TOOL, "category.gif"); + public static final ImageDescriptor CATEGORY_NEW = create(T_TOOL, "category-new.gif"); + public static final ImageDescriptor CATEGORY_QUERY = create(T_TOOL, "category-query.gif"); + public static final ImageDescriptor CATEGORY_QUERY_NEW = create(T_TOOL, "category-query-new.gif"); + public static final ImageDescriptor TASK_ACTIVE = create(T_TOOL, "task-active.gif"); + public static final ImageDescriptor TASK_INACTIVE = create(T_TOOL, "task-inactive.gif"); + public static final ImageDescriptor TASK_COMPLETE = create(T_TOOL, "task-complete.gif"); + public static final ImageDescriptor TASK_INCOMPLETE = create(T_TOOL, "task-incomplete.gif"); + public static final ImageDescriptor TASK_BUG_REFRESH = create(T_TOOL, "task-bug-refresh.gif"); + + private static ImageDescriptor create(String prefix, String name) { + try { + return ImageDescriptor.createFromURL(makeIconFileURL(prefix, name)); + } catch (MalformedURLException e) { + return ImageDescriptor.getMissingImageDescriptor(); + } + } + + private static URL makeIconFileURL(String prefix, String name) throws MalformedURLException { + if (baseURL == null) + throw new MalformedURLException(); + + StringBuffer buffer= new StringBuffer(prefix); + buffer.append('/'); + buffer.append(name); + return new URL(baseURL, buffer.toString()); + } + + /** + * Lazily initializes image map. + */ + public static Image getImage(ImageDescriptor imageDescriptor) { + Image image = imageMap.get(imageDescriptor); + if (image == null) { + image = imageDescriptor.createImage(); + imageMap.put(imageDescriptor, image); + } + return image; + } +} diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskListManager.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskListManager.java index b1dd5f9b0..738a97255 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskListManager.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/TaskListManager.java @@ -19,7 +19,6 @@ import java.util.List; import org.eclipse.mylar.core.MylarPlugin; import org.eclipse.mylar.tasks.util.RelativePathUtil; -import org.eclipse.mylar.tasks.util.XmlUtil; /** @@ -27,14 +26,14 @@ import org.eclipse.mylar.tasks.util.XmlUtil; */ public class TaskListManager { - private File file; + private File taskListFile; private TaskList taskList = new TaskList(); private List<ITaskActivityListener> listeners = new ArrayList<ITaskActivityListener>(); private int nextTaskId; public TaskListManager(File file) { - this.file = file; - if (MylarPlugin.getDefault().getPreferenceStore().contains(MylarTasksPlugin.TASK_ID)) { // TODO: fix to MylarTasksPlugin + this.taskListFile = file; + if (MylarPlugin.getDefault() != null && MylarPlugin.getDefault().getPreferenceStore().contains(MylarTasksPlugin.TASK_ID)) { // TODO: fix to MylarTasksPlugin nextTaskId = MylarPlugin.getDefault().getPreferenceStore().getInt(MylarTasksPlugin.TASK_ID); } else { nextTaskId = 1; @@ -51,8 +50,8 @@ public class TaskListManager { public boolean readTaskList() { try { - if (file.exists()) { - XmlUtil.readTaskList(taskList, file); + if (taskListFile.exists()) { + MylarTasksPlugin.getDefault().getTaskListExternalizer().readTaskList(taskList, taskListFile); int maxHandle = taskList.findLargestTaskHandle(); if (maxHandle >= nextTaskId) { nextTaskId = maxHandle + 1; @@ -61,18 +60,17 @@ public class TaskListManager { } return true; } catch (Exception e) { - MylarPlugin.log(e, "task read failed"); + MylarPlugin.log(e, "Could not read task list"); return false; } } public void saveTaskList() { try { - XmlUtil.writeTaskList(taskList, file); + MylarTasksPlugin.getDefault().getTaskListExternalizer().writeTaskList(taskList, taskListFile); MylarPlugin.getDefault().getPreferenceStore().setValue(MylarTasksPlugin.TASK_ID, nextTaskId); } catch (Exception e) { - e.printStackTrace(); // TODO: fix -// MylarPlugin.fail(e, "Could not save task list", true); + MylarPlugin.fail(e, "Could not save task list", true); } } @@ -150,14 +148,14 @@ public class TaskListManager { // updateTaskscapeReferenceHelper(task.getChildren(), prevDir); } } - public void setFile(File f) { - if (this.file.exists()) { - this.file.delete(); + public void setTaskListFile(File f) { + if (this.taskListFile.exists()) { + this.taskListFile.delete(); } - this.file = f; - } - - public void activateHit(BugzillaHit hit) { - + this.taskListFile = f; } + + public File getTaskListFile() { + return taskListFile; + } } diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TaskSummaryEditor.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TaskSummaryEditor.java index 7ab14f26b..2ddd6cd38 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TaskSummaryEditor.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TaskSummaryEditor.java @@ -41,15 +41,13 @@ import org.eclipse.jface.viewers.TextCellEditor; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerSorter; import org.eclipse.mylar.core.MylarPlugin; -import org.eclipse.mylar.tasks.BugzillaTask; import org.eclipse.mylar.tasks.ITask; import org.eclipse.mylar.tasks.ITaskActivityListener; +import org.eclipse.mylar.tasks.TaskListImages; import org.eclipse.mylar.tasks.MylarTasksPlugin; import org.eclipse.mylar.tasks.RelatedLinks; import org.eclipse.mylar.tasks.ui.views.TaskListView; import org.eclipse.mylar.tasks.util.RelativePathUtil; -import org.eclipse.mylar.ui.MylarImages; -import org.eclipse.mylar.ui.MylarUiPlugin; import org.eclipse.swt.SWT; import org.eclipse.swt.SWTException; import org.eclipse.swt.events.FocusEvent; @@ -99,6 +97,12 @@ import org.eclipse.ui.part.EditorPart; * @author Ken Sueda */ public class TaskSummaryEditor extends EditorPart { + + /** + * TODO: use workbench theme + */ + public static final Color HYPERLINK = new Color(Display.getDefault(), 0, 0, 255); + private ITask task; private TaskEditorInput editorInput; private Composite editorComposite; @@ -317,7 +321,7 @@ public class TaskSummaryEditor extends EditorPart { TableWrapData td = new TableWrapData(TableWrapData.FILL_GRAB); td.colspan = 2; description.setLayoutData(td); - if (task instanceof BugzillaTask) { + if (task.canEditDescription()) { description.setEnabled(false); } else { description.addFocusListener(new FocusListener() { @@ -673,7 +677,7 @@ public class TaskSummaryEditor extends EditorPart { } public Color getForeground(Object element) { - return MylarUiPlugin.getDefault().getColorMap().HYPERLINK; + return HYPERLINK; } public Color getBackground(Object element) { @@ -704,7 +708,7 @@ public class TaskSummaryEditor extends EditorPart { return null; } public Color getForeground(Object element) { - return MylarUiPlugin.getDefault().getColorMap().HYPERLINK; + return HYPERLINK; } public Color getBackground(Object element) { @@ -790,7 +794,7 @@ public class TaskSummaryEditor extends EditorPart { }; delete.setText("Delete"); delete.setToolTipText("Delete"); - delete.setImageDescriptor(MylarImages.REMOVE); + delete.setImageDescriptor(TaskListImages.REMOVE); add = new Action() { @Override diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/ClearContextAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/ClearContextAction.java index a0566e3a4..29cf2c923 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/ClearContextAction.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/ClearContextAction.java @@ -15,12 +15,10 @@ import org.eclipse.jface.action.Action; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.mylar.core.MylarPlugin; -import org.eclipse.mylar.tasks.BugzillaHit; -import org.eclipse.mylar.tasks.BugzillaTask; import org.eclipse.mylar.tasks.ITask; +import org.eclipse.mylar.tasks.TaskListImages; import org.eclipse.mylar.tasks.Task; import org.eclipse.mylar.tasks.ui.views.TaskListView; -import org.eclipse.mylar.ui.MylarImages; import org.eclipse.ui.internal.Workbench; /** @@ -37,7 +35,7 @@ public class ClearContextAction extends Action { setText("Clear Task Context"); setToolTipText("Clear Task Context"); setId(ID); - setImageDescriptor(MylarImages.ERASE_TASKSCAPE); + setImageDescriptor(TaskListImages.ERASE_TASKSCAPE); } @Override @@ -53,24 +51,26 @@ public class ClearContextAction extends Action { MylarPlugin.getTaskscapeManager().taskDeleted(((ITask)selectedObject).getHandle(), ((Task)selectedObject).getPath()); this.view.getViewer().refresh(); - } else if (selectedObject != null && selectedObject instanceof BugzillaHit) { - BugzillaTask task = ((BugzillaHit)selectedObject).getAssociatedTask(); - if(task != null){ - if (task.isActive()) { - MessageDialog.openError(Workbench.getInstance() - .getActiveWorkbenchWindow().getShell(), "Clear context failed", - "Task must be deactivated before clearing task context."); - return; - } - boolean deleteConfirmed = MessageDialog.openQuestion( - Workbench.getInstance().getActiveWorkbenchWindow().getShell(), - "Confirm clear context", - "Clear context for the selected task?"); - if (!deleteConfirmed) - return; - MylarPlugin.getTaskscapeManager().taskDeleted(task.getHandle(), task.getPath()); - } - this.view.getViewer().refresh(); - } + } + // XXX: refactored put this somewhere +// else if (selectedObject != null && selectedObject instanceof BugzillaHit) { +// BugzillaTask task = ((BugzillaHit)selectedObject).getAssociatedTask(); +// if(task != null){ +// if (task.isActive()) { +// MessageDialog.openError(Workbench.getInstance() +// .getActiveWorkbenchWindow().getShell(), "Clear context failed", +// "Task must be deactivated before clearing task context."); +// return; +// } +// boolean deleteConfirmed = MessageDialog.openQuestion( +// Workbench.getInstance().getActiveWorkbenchWindow().getShell(), +// "Confirm clear context", +// "Clear context for the selected task?"); +// if (!deleteConfirmed) +// return; +// MylarPlugin.getTaskscapeManager().taskDeleted(task.getHandle(), task.getPath()); +// } +// this.view.getViewer().refresh(); +// } } }
\ No newline at end of file diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/CreateCategoryAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/CreateCategoryAction.java index 9720835dc..1e865d23c 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/CreateCategoryAction.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/CreateCategoryAction.java @@ -12,10 +12,10 @@ package org.eclipse.mylar.tasks.ui.actions; import org.eclipse.jface.action.Action; +import org.eclipse.mylar.tasks.TaskListImages; import org.eclipse.mylar.tasks.MylarTasksPlugin; import org.eclipse.mylar.tasks.TaskCategory; import org.eclipse.mylar.tasks.ui.views.TaskListView; -import org.eclipse.mylar.ui.MylarImages; /** * @author Mik Kersten and Ken Sueda @@ -31,7 +31,7 @@ public class CreateCategoryAction extends Action { setText("Add Category"); setToolTipText("Add Category"); setId(ID); - setImageDescriptor(MylarImages.CATEGORY_NEW); + setImageDescriptor(TaskListImages.CATEGORY_NEW); } @Override diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/CreateTaskAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/CreateTaskAction.java index b696a13ce..9c2c9d318 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/CreateTaskAction.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/CreateTaskAction.java @@ -13,12 +13,11 @@ package org.eclipse.mylar.tasks.ui.actions; import org.eclipse.jface.action.Action; import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.mylar.tasks.TaskListImages; import org.eclipse.mylar.tasks.MylarTasksPlugin; import org.eclipse.mylar.tasks.Task; import org.eclipse.mylar.tasks.TaskCategory; import org.eclipse.mylar.tasks.ui.views.TaskListView; -import org.eclipse.mylar.ui.MylarImages; -import org.eclipse.mylar.ui.MylarUiPlugin; /** * @author Mik Kersten and Ken Sueda @@ -34,7 +33,7 @@ public class CreateTaskAction extends Action { setText("Add Task"); setToolTipText("Add Task"); setId(ID); - setImageDescriptor(MylarImages.TASK_NEW); + setImageDescriptor(TaskListImages.TASK_NEW); } @Override @@ -62,9 +61,9 @@ public class CreateTaskAction extends Action { else { MylarTasksPlugin.getTaskListManager().getTaskList().addRootTask(newTask); } - MylarUiPlugin.getDefault().setHighlighterMapping( - newTask.getHandle(), - MylarUiPlugin.getDefault().getDefaultHighlighter().getName()); +// MylarUiPlugin.getDefault().setHighlighterMapping( +// newTask.getHandle(), +// MylarUiPlugin.getDefault().getDefaultHighlighter().getName()); this.view.getViewer().refresh(); } }
\ No newline at end of file diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/DeleteAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/DeleteAction.java index 4254cf0bc..71c21acf2 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/DeleteAction.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/DeleteAction.java @@ -15,13 +15,11 @@ import org.eclipse.jface.action.Action; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.mylar.core.MylarPlugin; -import org.eclipse.mylar.tasks.BugzillaQueryCategory; -import org.eclipse.mylar.tasks.BugzillaTask; import org.eclipse.mylar.tasks.ITask; +import org.eclipse.mylar.tasks.TaskListImages; import org.eclipse.mylar.tasks.MylarTasksPlugin; import org.eclipse.mylar.tasks.TaskCategory; import org.eclipse.mylar.tasks.ui.views.TaskListView; -import org.eclipse.mylar.ui.MylarImages; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.internal.Workbench; @@ -38,7 +36,7 @@ public class DeleteAction extends Action { this.view = view; setText("Delete"); setId(ID); - setImageDescriptor(MylarImages.REMOVE); + setImageDescriptor(TaskListImages.REMOVE); } @Override @@ -55,12 +53,7 @@ public class DeleteAction extends Action { return; } - String message = ""; - if (selectedObject instanceof BugzillaTask) { - message = "Remove this report from the task list, and discard any task context or local notes?"; - } else { - message = "Delete the selected task and discard task context?"; - } + String message = task.getDeleteConfirmationMessage(); boolean deleteConfirmed = MessageDialog.openQuestion( Workbench.getInstance().getActiveWorkbenchWindow().getShell(), "Confirm delete", message); @@ -99,16 +92,17 @@ public class DeleteAction extends Action { } } } - MylarTasksPlugin.getTaskListManager().deleteCategory((TaskCategory) selectedObject); - } else if (selectedObject instanceof BugzillaQueryCategory) { - boolean deleteConfirmed = MessageDialog.openQuestion( - Workbench.getInstance().getActiveWorkbenchWindow().getShell(), - "Confirm delete", - "Delete the selected query and all contained tasks?"); - if (!deleteConfirmed) - return; - BugzillaQueryCategory cat = (BugzillaQueryCategory) selectedObject; MylarTasksPlugin.getTaskListManager().deleteCategory(cat); + // XXX refactored +// } else if (selectedObject instanceof BugzillaQueryCategory) { +// boolean deleteConfirmed = MessageDialog.openQuestion( +// Workbench.getInstance().getActiveWorkbenchWindow().getShell(), +// "Confirm delete", +// "Delete the selected query and all contained tasks?"); +// if (!deleteConfirmed) +// return; +// BugzillaQueryCategory cat = (BugzillaQueryCategory) selectedObject; +// MylarTasksPlugin.getTaskListManager().deleteCategory(cat); } else { MessageDialog.openError(Workbench.getInstance() .getActiveWorkbenchWindow().getShell(), "Delete failed", diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/FilterCompletedTasksAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/FilterCompletedTasksAction.java index 1872b725c..a63c707c7 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/FilterCompletedTasksAction.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/FilterCompletedTasksAction.java @@ -12,9 +12,9 @@ package org.eclipse.mylar.tasks.ui.actions; import org.eclipse.jface.action.Action; +import org.eclipse.mylar.tasks.TaskListImages; import org.eclipse.mylar.tasks.MylarTasksPlugin; import org.eclipse.mylar.tasks.ui.views.TaskListView; -import org.eclipse.mylar.ui.MylarImages; /** * @author Mik Kersten and Ken Sueda @@ -30,7 +30,7 @@ public class FilterCompletedTasksAction extends Action { setText("Filter Completed Tasks"); setToolTipText("Filter Completed Tasks"); setId(ID); - setImageDescriptor(MylarImages.FILTER_COMPLETE); + setImageDescriptor(TaskListImages.FILTER_COMPLETE); setChecked(MylarTasksPlugin.getDefault().isFilterCompleteMode()); } @Override diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/MarkTaskCompleteAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/MarkTaskCompleteAction.java index 2ef8cdb61..ed00ec76e 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/MarkTaskCompleteAction.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/MarkTaskCompleteAction.java @@ -13,9 +13,9 @@ package org.eclipse.mylar.tasks.ui.actions; import org.eclipse.jface.action.Action; import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.mylar.tasks.TaskListImages; import org.eclipse.mylar.tasks.Task; import org.eclipse.mylar.tasks.ui.views.TaskListView; -import org.eclipse.mylar.ui.MylarImages; /** * @author Mik Kersten and Ken Sueda @@ -31,7 +31,7 @@ public class MarkTaskCompleteAction extends Action { setText("Mark Complete"); setToolTipText("Mark Complete"); setId(ID); - setImageDescriptor(MylarImages.TASK_COMPLETE); + setImageDescriptor(TaskListImages.TASK_COMPLETE); } @Override public void run() { diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/MarkTaskIncompleteAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/MarkTaskIncompleteAction.java index d990812c7..759e27cd6 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/MarkTaskIncompleteAction.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/MarkTaskIncompleteAction.java @@ -13,9 +13,9 @@ package org.eclipse.mylar.tasks.ui.actions; import org.eclipse.jface.action.Action; import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.mylar.tasks.TaskListImages; import org.eclipse.mylar.tasks.Task; import org.eclipse.mylar.tasks.ui.views.TaskListView; -import org.eclipse.mylar.ui.MylarImages; /** * @author Mik Kersten and Ken Sueda @@ -31,7 +31,7 @@ public class MarkTaskIncompleteAction extends Action { setText("Mark Incomplete"); setToolTipText("Mark Incomplete"); setId(ID); - setImageDescriptor(MylarImages.TASK_INCOMPLETE); + setImageDescriptor(TaskListImages.TASK_INCOMPLETE); } @Override public void run() { diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/MoveTaskToRootAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/MoveTaskToRootAction.java index cb49a7c8e..d3a0a3d3c 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/MoveTaskToRootAction.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/MoveTaskToRootAction.java @@ -12,11 +12,6 @@ package org.eclipse.mylar.tasks.ui.actions; import org.eclipse.jface.action.Action; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.mylar.tasks.ITask; -import org.eclipse.mylar.tasks.MylarTasksPlugin; -import org.eclipse.mylar.tasks.TaskCategory; import org.eclipse.mylar.tasks.ui.views.TaskListView; /** @@ -35,23 +30,24 @@ public class MoveTaskToRootAction extends Action { } @Override public void run() { - ISelection selection = this.view.getViewer().getSelection(); - Object obj = ((IStructuredSelection)selection).getFirstElement(); - if (obj instanceof ITask) { - ITask t = (ITask) obj; - TaskCategory cat = t.getCategory(); - if (cat != null) { - cat.removeTask(t); - t.setCategory(null); - t.setParent(null); - MylarTasksPlugin.getTaskListManager().getTaskList().addRootTask(t); - this.view.getViewer().refresh(); - } else if (t.getParent() != null) { - t.getParent().removeSubTask(t); - t.setParent(null); - MylarTasksPlugin.getTaskListManager().getTaskList().addRootTask(t); - this.view.getViewer().refresh(); - } - } + throw new RuntimeException("unimplemented"); +// ISelection selection = this.view.getViewer().getSelection(); +// Object obj = ((IStructuredSelection)selection).getFirstElement(); +// if (obj instanceof ITask) { +// ITask t = (ITask) obj; +// TaskCategory cat = t.getCategory(); +// if (cat != null) { +// cat.removeTask(t); +// t.setCategory(null); +// t.setParent(null); +// MylarTasksPlugin.getTaskListManager().getTaskList().addRootTask(t); +// this.view.getViewer().refresh(); +// } else if (t.getParent() != null) { +// t.getParent().removeSubTask(t); +// t.setParent(null); +// MylarTasksPlugin.getTaskListManager().getTaskList().addRootTask(t); +// this.view.getViewer().refresh(); +// } +// } } }
\ No newline at end of file diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/OpenTaskEditorAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/OpenTaskEditorAction.java index f345a097f..38bbf196f 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/OpenTaskEditorAction.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/OpenTaskEditorAction.java @@ -13,22 +13,9 @@ package org.eclipse.mylar.tasks.ui.actions; import java.net.MalformedURLException; import java.net.URL; -import java.util.ArrayList; -import java.util.List; import org.eclipse.jface.action.Action; -import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.mylar.bugzilla.ui.BugzillaOpenStructure; -import org.eclipse.mylar.bugzilla.ui.ViewBugzillaAction; -import org.eclipse.mylar.tasks.BugzillaHit; -import org.eclipse.mylar.tasks.BugzillaQueryCategory; -import org.eclipse.mylar.tasks.BugzillaTask; -import org.eclipse.mylar.tasks.ITask; -import org.eclipse.mylar.tasks.MylarTasksPlugin; -import org.eclipse.mylar.tasks.ui.views.BugzillaQueryDialog; import org.eclipse.mylar.tasks.ui.views.TaskListView; import org.eclipse.swt.widgets.Display; import org.eclipse.ui.PartInitException; @@ -54,54 +41,55 @@ public class OpenTaskEditorAction extends Action { @Override public void run() { -// MylarPlugin.getDefault().actionObserved(this); - ISelection selection = this.view.getViewer().getSelection(); - Object obj = ((IStructuredSelection)selection).getFirstElement(); - if (obj instanceof ITask) { - if (obj instanceof BugzillaTask) { - BugzillaTask t = (BugzillaTask) obj; - MylarTasksPlugin.Report_Open_Mode mode = MylarTasksPlugin.getDefault().getReportMode(); - if (mode == MylarTasksPlugin.Report_Open_Mode.EDITOR) { - t.openTaskInEditor(); - } else if (mode == MylarTasksPlugin.Report_Open_Mode.INTERNAL_BROWSER) { - openUrl(t.getBugUrl()); - } else { - // not supported - } - } else { - ((ITask)obj).openTaskInEditor(); - } - } else if (obj instanceof BugzillaQueryCategory){ - - BugzillaQueryDialog sqd = new BugzillaQueryDialog(Display.getCurrent().getActiveShell()); - if(sqd.open() == Dialog.OK){ - BugzillaQueryCategory queryCategory = (BugzillaQueryCategory)obj; - queryCategory.setDescription(sqd.getName()); - queryCategory.setUrl(sqd.getUrl()); - - queryCategory.refreshBugs(); - this.view.getViewer().refresh(); - } - } else if(obj instanceof BugzillaHit){ - BugzillaHit hit = (BugzillaHit)obj; - MylarTasksPlugin.Report_Open_Mode mode = MylarTasksPlugin.getDefault().getReportMode(); - if (mode == MylarTasksPlugin.Report_Open_Mode.EDITOR) { - if(hit.isTask()){ - hit.getAssociatedTask().openTaskInEditor(); - } else { - BugzillaOpenStructure open = new BugzillaOpenStructure(((BugzillaHit)obj).getServerName(), ((BugzillaHit)obj).getID(),-1); - List<BugzillaOpenStructure> selectedBugs = new ArrayList<BugzillaOpenStructure>(); - selectedBugs.add(open); - ViewBugzillaAction viewBugs = new ViewBugzillaAction("Display bugs in editor", selectedBugs); - viewBugs.schedule(); - } - } else if (mode == MylarTasksPlugin.Report_Open_Mode.INTERNAL_BROWSER) { - openUrl(hit.getBugUrl()); - } else { - // not supported - } - } - this.view.getViewer().refresh(obj); + throw new RuntimeException("unimplemented"); + // XXX refactored +// ISelection selection = this.view.getViewer().getSelection(); +// Object obj = ((IStructuredSelection)selection).getFirstElement(); +// if (obj instanceof ITask) { +// if (obj instanceof BugzillaTask) { +// BugzillaTask t = (BugzillaTask) obj; +// MylarTasksPlugin.Report_Open_Mode mode = MylarTasksPlugin.getDefault().getReportMode(); +// if (mode == MylarTasksPlugin.Report_Open_Mode.EDITOR) { +// t.openTaskInEditor(); +// } else if (mode == MylarTasksPlugin.Report_Open_Mode.INTERNAL_BROWSER) { +// openUrl(t.getBugUrl()); +// } else { +// // not supported +// } +// } else { +// ((ITask)obj).openTaskInEditor(); +// } +// } else if (obj instanceof BugzillaQueryCategory){ +// +// BugzillaQueryDialog sqd = new BugzillaQueryDialog(Display.getCurrent().getActiveShell()); +// if(sqd.open() == Dialog.OK){ +// BugzillaQueryCategory queryCategory = (BugzillaQueryCategory)obj; +// queryCategory.setDescription(sqd.getName()); +// queryCategory.setUrl(sqd.getUrl()); +// +// queryCategory.refreshBugs(); +// this.view.getViewer().refresh(); +// } +// } else if(obj instanceof BugzillaHit){ +// BugzillaHit hit = (BugzillaHit)obj; +// MylarTasksPlugin.Report_Open_Mode mode = MylarTasksPlugin.getDefault().getReportMode(); +// if (mode == MylarTasksPlugin.Report_Open_Mode.EDITOR) { +// if(hit.isTask()){ +// hit.getAssociatedTask().openTaskInEditor(); +// } else { +// BugzillaOpenStructure open = new BugzillaOpenStructure(((BugzillaHit)obj).getServerName(), ((BugzillaHit)obj).getID(),-1); +// List<BugzillaOpenStructure> selectedBugs = new ArrayList<BugzillaOpenStructure>(); +// selectedBugs.add(open); +// ViewBugzillaAction viewBugs = new ViewBugzillaAction("Display bugs in editor", selectedBugs); +// viewBugs.schedule(); +// } +// } else if (mode == MylarTasksPlugin.Report_Open_Mode.INTERNAL_BROWSER) { +// openUrl(hit.getBugUrl()); +// } else { +// // not supported +// } +// } +// this.view.getViewer().refresh(obj); } private void openUrl(String url) { diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/TaskActivateAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/TaskActivateAction.java index 25d0ea42a..1983b0d3c 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/TaskActivateAction.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/TaskActivateAction.java @@ -30,7 +30,6 @@ public class TaskActivateAction extends Action { } public void run() { -// MylarPlugin.getDefault().actionObserved(this); MylarTasksPlugin.getTaskListManager().activateTask(task); } }
\ No newline at end of file diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/ToggleIntersectionModeAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/ToggleIntersectionModeAction.java index d74bf6cf7..a01d1c907 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/ToggleIntersectionModeAction.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/actions/ToggleIntersectionModeAction.java @@ -14,21 +14,20 @@ package org.eclipse.mylar.tasks.ui.actions; import org.eclipse.jface.action.Action; -import org.eclipse.mylar.core.ITaskscapeListener; import org.eclipse.mylar.core.MylarPlugin; -import org.eclipse.mylar.ui.MylarImages; -import org.eclipse.mylar.ui.MylarUiPlugin; +import org.eclipse.mylar.tasks.TaskListImages; /** * @author Mik Kersten */ +@Deprecated public class ToggleIntersectionModeAction extends Action { public ToggleIntersectionModeAction() { super(); setText("Intersect Tasskscapes"); setToolTipText("Intersect Taskscapes"); - setImageDescriptor(MylarImages.MYLAR); +// setImageDescriptor(TaskListImages.); setActionDefinitionId("org.eclipse.mylar.ui.interest.intersection"); // setChecked(MylarUiPlugin.getDefault().isGlobalFilteringEnabled()); } @@ -36,7 +35,8 @@ public class ToggleIntersectionModeAction extends Action { @Override public void run() { setChecked(!isChecked()); - MylarUiPlugin.getDefault().setIntersectionMode(isChecked()); - MylarPlugin.getTaskscapeManager().notifyActivePresentationSettingsChange(ITaskscapeListener.UpdateKind.HIGHLIGHTER); + MylarPlugin.log("not implemented", this); +// MylarUiPlugin.getDefault().setIntersectionMode(isChecked()); +// MylarPlugin.getTaskscapeManager().notifyActivePresentationSettingsChange(ITaskscapeListener.UpdateKind.HIGHLIGHTER); } } diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/views/TaskListLabelProvider.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/views/TaskListLabelProvider.java index a6af5e8d8..eba348ed3 100644 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/views/TaskListLabelProvider.java +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/views/TaskListLabelProvider.java @@ -18,15 +18,7 @@ import org.eclipse.jface.viewers.IFontProvider; import org.eclipse.jface.viewers.ITableLabelProvider; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.mylar.tasks.AbstractCategory; -import org.eclipse.mylar.tasks.BugzillaHit; -import org.eclipse.mylar.tasks.BugzillaQueryCategory; -import org.eclipse.mylar.tasks.BugzillaTask; -import org.eclipse.mylar.tasks.ITask; import org.eclipse.mylar.tasks.ITaskListElement; -import org.eclipse.mylar.tasks.TaskCategory; -import org.eclipse.mylar.ui.MylarUiPlugin; -import org.eclipse.mylar.ui.internal.UiUtil; -import org.eclipse.mylar.ui.internal.views.Highlighter; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.Image; @@ -59,44 +51,43 @@ public class TaskListLabelProvider extends LabelProvider implements ITableLabelP } public Font getFont(Object element) { - if (element instanceof ITask) { - ITask task = (ITask)element; - if (task.isActive()) return UiUtil.BOLD; -// if (task.isCompleted()) return UiUtil.ITALIC; - for (ITask child : task.getChildren()) { - if (child.isActive()) - return UiUtil.BOLD; - } - if (task instanceof BugzillaTask) { - if (((BugzillaTask)task).getState() != BugzillaTask.BugTaskState.FREE) { - return UiUtil.ITALIC; - } - } - } else if (element instanceof TaskCategory) { - TaskCategory cat = (TaskCategory) element; - for (ITask child : cat.getChildren()) { - if (child.isActive()) - return UiUtil.BOLD; - } - } else if (element instanceof BugzillaHit) { - BugzillaHit hit = (BugzillaHit)element; - BugzillaTask task = hit.getAssociatedTask(); - if(task != null){ - if (task.isActive()) return UiUtil.BOLD; -// if (task.isCompleted()) return UiUtil.ITALIC; - } - } else if (element instanceof BugzillaQueryCategory) { - BugzillaQueryCategory cat = (BugzillaQueryCategory) element; - for (ITaskListElement child : cat.getHits()) { - if (child instanceof BugzillaHit){ - BugzillaHit hit = (BugzillaHit) child; - BugzillaTask task = hit.getAssociatedTask(); - if(task != null && task.isActive()){ - return UiUtil.BOLD; - } - } - } - } + // XXX refactored +// if (element instanceof ITask) { +// ITask task = (ITask)element; +// if (task.isActive()) return UiUtil.BOLD; +// for (ITask child : task.getChildren()) { +// if (child.isActive()) +// return UiUtil.BOLD; +// } +// if (task instanceof BugzillaTask) { +// if (((BugzillaTask)task).getState() != BugzillaTask.BugTaskState.FREE) { +// return UiUtil.ITALIC; +// } +// } +// } else if (element instanceof TaskCategory) { +// TaskCategory cat = (TaskCategory) element; +// for (ITask child : cat.getChildren()) { +// if (child.isActive()) +// return UiUtil.BOLD; +// } +// } else if (element instanceof BugzillaHit) { +// BugzillaHit hit = (BugzillaHit)element; +// BugzillaTask task = hit.getAssociatedTask(); +// if(task != null){ +// if (task.isActive()) return UiUtil.BOLD; +// } +// } else if (element instanceof BugzillaQueryCategory) { +// BugzillaQueryCategory cat = (BugzillaQueryCategory) element; +// for (ITaskListElement child : cat.getHits()) { +// if (child instanceof BugzillaHit){ +// BugzillaHit hit = (BugzillaHit) child; +// BugzillaTask task = hit.getAssociatedTask(); +// if(task != null && task.isActive()){ +// return UiUtil.BOLD; +// } +// } +// } +// } return null; } @@ -121,32 +112,34 @@ public class TaskListLabelProvider extends LabelProvider implements ITableLabelP } public Color getBackground(Object element) { - if (element instanceof ITask) { - ITask task = (ITask)element; - Highlighter highlighter = MylarUiPlugin.getDefault().getHighlighterForTaskId("" + task.getHandle()); - if (highlighter != null) return highlighter.getHighlightColor(); - } else if (element instanceof BugzillaHit) { - BugzillaHit hit = (BugzillaHit)element; - BugzillaTask task = hit.getAssociatedTask(); - if(task != null){ - Highlighter highlighter = MylarUiPlugin.getDefault().getHighlighterForTaskId("" + task.getHandle()); - if (highlighter != null) return highlighter.getHighlightColor(); - } - }else if (element instanceof AbstractCategory) { - return backgroundColor; - } - return null; + // XXX refactored +// if (element instanceof ITask) { +// ITask task = (ITask)element; +// Highlighter highlighter = MylarUiPlugin.getDefault().getHighlighterForTaskId("" + task.getHandle()); +// if (highlighter != null) return highlighter.getHighlightColor(); +// } else if (element instanceof BugzillaHit) { +// BugzillaHit hit = (BugzillaHit)element; +// BugzillaTask task = hit.getAssociatedTask(); +// if(task != null){ +// Highlighter highlighter = MylarUiPlugin.getDefault().getHighlighterForTaskId("" + task.getHandle()); +// if (highlighter != null) return highlighter.getHighlightColor(); +// } +// }else if (element instanceof AbstractCategory) { +// return backgroundColor; +// } + return null; } public Color getForeground(Object element) { - if (element instanceof ITask) { - ITask task = (ITask)element; - if (task.isCompleted()) return MylarUiPlugin.getDefault().getColorMap().GRAY_VERY_LIGHT; - } else if (element instanceof BugzillaHit) { - BugzillaHit hit = (BugzillaHit)element; - BugzillaTask task = hit.getAssociatedTask(); - if (task != null && task.isCompleted()) return MylarUiPlugin.getDefault().getColorMap().GRAY_VERY_LIGHT; - } + // XXX refactored +// if (element instanceof ITask) { +// ITask task = (ITask)element; +// if (task.isCompleted()) return MylarUiPlugin.getDefault().getColorMap().GRAY_VERY_LIGHT; +// } else if (element instanceof BugzillaHit) { +// BugzillaHit hit = (BugzillaHit)element; +// BugzillaTask task = hit.getAssociatedTask(); +// if (task != null && task.isCompleted()) return MylarUiPlugin.getDefault().getColorMap().GRAY_VERY_LIGHT; +// } return null; } 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 6ed74c895..49e6d1627 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 @@ -14,13 +14,13 @@ package org.eclipse.mylar.tasks.ui.views; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; -import java.util.Iterator; import java.util.List; import javax.security.auth.login.LoginException; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.ActionContributionItem; +import org.eclipse.jface.action.IAction; import org.eclipse.jface.action.IMenuCreator; import org.eclipse.jface.action.IMenuListener; import org.eclipse.jface.action.IMenuManager; @@ -48,39 +48,26 @@ import org.eclipse.jface.viewers.ViewerDropAdapter; import org.eclipse.jface.viewers.ViewerFilter; import org.eclipse.jface.viewers.ViewerSorter; import org.eclipse.jface.window.Window; -import org.eclipse.mylar.core.ITaskscapeListener; import org.eclipse.mylar.core.MylarPlugin; import org.eclipse.mylar.dt.MylarWebRef; import org.eclipse.mylar.tasks.AbstractCategory; -import org.eclipse.mylar.tasks.BugzillaHit; -import org.eclipse.mylar.tasks.BugzillaQueryCategory; -import org.eclipse.mylar.tasks.BugzillaTask; import org.eclipse.mylar.tasks.ITask; import org.eclipse.mylar.tasks.ITaskListElement; +import org.eclipse.mylar.tasks.TaskListImages; import org.eclipse.mylar.tasks.MylarTasksPlugin; import org.eclipse.mylar.tasks.Task; import org.eclipse.mylar.tasks.TaskCategory; -import org.eclipse.mylar.tasks.ui.BugzillaTaskEditorInput; import org.eclipse.mylar.tasks.ui.TaskEditorInput; import org.eclipse.mylar.tasks.ui.actions.ClearContextAction; -import org.eclipse.mylar.tasks.ui.actions.CreateBugzillaQueryCategoryAction; -import org.eclipse.mylar.tasks.ui.actions.CreateBugzillaTaskAction; import org.eclipse.mylar.tasks.ui.actions.CreateCategoryAction; import org.eclipse.mylar.tasks.ui.actions.CreateTaskAction; import org.eclipse.mylar.tasks.ui.actions.DeleteAction; import org.eclipse.mylar.tasks.ui.actions.FilterCompletedTasksAction; 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.RefreshBugzillaAction; -import org.eclipse.mylar.tasks.ui.actions.RefreshBugzillaReportsAction; import org.eclipse.mylar.tasks.ui.actions.TaskActivateAction; import org.eclipse.mylar.tasks.ui.actions.TaskDeactivateAction; -import org.eclipse.mylar.ui.MylarImages; -import org.eclipse.mylar.ui.MylarUiPlugin; -import org.eclipse.mylar.ui.internal.views.Highlighter; -import org.eclipse.mylar.ui.internal.views.HighlighterImageDescriptor; import org.eclipse.swt.SWT; import org.eclipse.swt.dnd.DND; import org.eclipse.swt.dnd.DragSourceEvent; @@ -123,15 +110,14 @@ public class TaskListView extends ViewPart { private static TaskListView INSTANCE; + private List<IAction> contributedActions = new ArrayList<IAction>(); + TreeViewer viewer; private DrillDownAdapter drillDownAdapter; - private RefreshBugzillaReportsAction refresh; private CreateTaskAction createTask; private CreateCategoryAction createCategory; - private CreateBugzillaQueryCategoryAction createBugzillaQueryCategory; - private CreateBugzillaTaskAction createBugzillaTask; -// private RenameAction rename; + private DeleteAction delete; private OpenTaskEditorAction doubleClickAction; private ClearContextAction clearSelectedTaskscapeAction; @@ -145,7 +131,6 @@ public class TaskListView extends ViewPart { // private FilterIncompleteTasksAction filterInCompleteTask; private PriorityDropDownAction filterOnPriority; private Action moveTaskToRoot; - private RefreshBugzillaAction refreshQuery; private PriorityFilter priorityFilter = new PriorityFilter(); protected String[] columnNames = new String[] { "", ".", "!", "Description" }; @@ -165,7 +150,7 @@ public class TaskListView extends ViewPart { super(); setText("Priority Filter"); setToolTipText("Filter priority lower than"); - setImageDescriptor(MylarImages.FILTER_PRIORITY); + setImageDescriptor(TaskListImages.FILTER_PRIORITY); setMenuCreator(this); } @@ -293,16 +278,19 @@ public class TaskListView extends ViewPart { public boolean select(Viewer viewer, Object parentElement, Object element) { if (element instanceof ITask) { return !((ITask)element).isCompleted(); - } else if (element instanceof BugzillaHit){ - BugzillaHit hit = (BugzillaHit)element; - BugzillaTask task = hit.getAssociatedTask(); - if (task != null) { - return !task.isCompleted(); - } - return true; - } else { - return true; - } + } + return false; + // XXX refactored +// else if (element instanceof BugzillaHit){ +// BugzillaHit hit = (BugzillaHit)element; +// BugzillaTask task = hit.getAssociatedTask(); +// if (task != null) { +// return !task.isCompleted(); +// } +// return true; +// } else { +// return true; +// } } }; @@ -402,9 +390,11 @@ public class TaskListView extends ViewPart { return ((TaskCategory)parent).getChildren().toArray(); } else if (parent instanceof Task) { return ((Task)parent).getChildren().toArray(); - } else if (parent instanceof BugzillaQueryCategory) { - return ((BugzillaQueryCategory) parent).getHits().toArray(); } + // XXX refactored +// else if (parent instanceof BugzillaQueryCategory) { +// return ((BugzillaQueryCategory) parent).getHits().toArray(); +// } return new Object[0]; } public boolean hasChildren(Object parent) { @@ -414,10 +404,12 @@ public class TaskListView extends ViewPart { } else if (parent instanceof Task) { Task t = (Task) parent; return t.getChildren() != null && t.getChildren().size() > 0; - } else if (parent instanceof BugzillaQueryCategory) { - BugzillaQueryCategory cat = (BugzillaQueryCategory)parent; - return cat.getHits() != null && cat.getHits().size() > 0; } + // XXX refactored +// else if (parent instanceof BugzillaQueryCategory) { +// BugzillaQueryCategory cat = (BugzillaQueryCategory)parent; +// return cat.getHits() != null && cat.getHits().size() > 0; +// } return false; } } @@ -435,8 +427,9 @@ public class TaskListView extends ViewPart { switch (columnIndex) { case 0: return true; case 1: return false; - case 2: return !(task instanceof BugzillaTask); - case 3: return !(task instanceof BugzillaTask); + // XXX refactored + case 2: return true;//!(task instanceof BugzillaTask); + case 3: return true;//!(task instanceof BugzillaTask); } } else if (element instanceof AbstractCategory) { switch (columnIndex) { @@ -446,13 +439,15 @@ public class TaskListView extends ViewPart { return false; case 3: return true; } - } else if (element instanceof BugzillaHit){ - if (columnIndex == 0) { - return true; - }else { - return false; - } - } + } + // XXX refactored +// else if (element instanceof BugzillaHit){ +// if (columnIndex == 0) { +// return true; +// }else { +// return false; +// } +// } return false; } @@ -483,24 +478,26 @@ public class TaskListView extends ViewPart { case 3: return cat.getDescription(true); } - } else if (element instanceof BugzillaHit) { - BugzillaHit hit = (BugzillaHit) element; - ITask task = hit.getAssociatedTask(); - switch (columnIndex) { - case 0: - if(task == null){ - return new Boolean(true); - } else { - return new Boolean(task.isCompleted()); - } - case 1: - return ""; - case 2: - String priorityString = hit.getPriority().substring(1); - return new Integer(priorityString); - case 3: - return hit.getDescription(true); - } + // XXX refactored +// } +// else if (element instanceof BugzillaHit) { +// BugzillaHit hit = (BugzillaHit) element; +// ITask task = hit.getAssociatedTask(); +// switch (columnIndex) { +// case 0: +// if(task == null){ +// return new Boolean(true); +// } else { +// return new Boolean(task.isCompleted()); +// } +// case 1: +// return ""; +// case 2: +// String priorityString = hit.getPriority().substring(1); +// return new Integer(priorityString); +// case 3: +// return hit.getDescription(true); +// } } return ""; } @@ -550,34 +547,36 @@ public class TaskListView extends ViewPart { viewer.setSelection(null); break; } - } else if (((TreeItem) element).getData() instanceof BugzillaHit) { - BugzillaHit hit = (BugzillaHit)((TreeItem) element).getData(); - switch (columnIndex) { - case 0: - BugzillaTask task = hit.getAssociatedTask(); - if(task == null){ - task = new BugzillaTask(hit); - hit.setAssociatedTask(task); - MylarTasksPlugin.getTaskListManager().getTaskList().addToBugzillaTaskRegistry(task); - // TODO move the task to a special folder - } - if (task.isActive()) { - MylarTasksPlugin.getTaskListManager() - .deactivateTask(task); - } else { - MylarTasksPlugin.getTaskListManager().activateTask( - task); - } - viewer.setSelection(null); - break; - case 1: - break; - case 2: - break; - case 3: - viewer.setSelection(null); - break; - } + // XXX refactored +// } +// else if (((TreeItem) element).getData() instanceof BugzillaHit) { +// BugzillaHit hit = (BugzillaHit)((TreeItem) element).getData(); +// switch (columnIndex) { +// case 0: +// BugzillaTask task = hit.getAssociatedTask(); +// if(task == null){ +// task = new BugzillaTask(hit); +// hit.setAssociatedTask(task); +// MylarTasksPlugin.getTaskListManager().getTaskList().addToBugzillaTaskRegistry(task); +// // TODO move the task to a special folder +// } +// if (task.isActive()) { +// MylarTasksPlugin.getTaskListManager() +// .deactivateTask(task); +// } else { +// MylarTasksPlugin.getTaskListManager().activateTask( +// task); +// } +// viewer.setSelection(null); +// break; +// case 1: +// break; +// case 2: +// break; +// case 3: +// viewer.setSelection(null); +// break; +// } } viewer.refresh(); } catch (Exception e) { @@ -619,11 +618,12 @@ public class TaskListView extends ViewPart { if (task1.isCompleted()) return 1; if (task2.isCompleted()) return -1; if (column == columnNames[1]) { - if (task1 instanceof BugzillaTask && !(task2 instanceof BugzillaTask)) { - return 1; - } else { - return -1; - } + // XXX refactored +// if (task1 instanceof BugzillaTask && !(task2 instanceof BugzillaTask)) { +// return 1; +// } else { +// return -1; +// } } else if (column == columnNames[2]) { return task1.getPriority().compareTo(task2.getPriority()); } else if (column == columnNames[3]) { @@ -632,19 +632,21 @@ public class TaskListView extends ViewPart { return 0; } } - } else if(o1 instanceof BugzillaHit && o2 instanceof BugzillaHit){ - BugzillaHit task1 = (BugzillaHit) o1; - BugzillaHit task2 = (BugzillaHit) o2; - - if (column == columnNames[1]) { - return 0; - } else if (column == columnNames[2]) { - return task1.getPriority().compareTo(task2.getPriority()); - } else if (column == columnNames[3]) { - return task1.getDescription(false).compareTo(task2.getDescription(false)); - } else { - return 0; - } +// } + // XXX refactored +// else if(o1 instanceof BugzillaHit && o2 instanceof BugzillaHit){ +// BugzillaHit task1 = (BugzillaHit) o1; +// BugzillaHit task2 = (BugzillaHit) o2; +// +// if (column == columnNames[1]) { +// return 0; +// } else if (column == columnNames[2]) { +// return task1.getPriority().compareTo(task2.getPriority()); +// } else if (column == columnNames[3]) { +// return task1.getDescription(false).compareTo(task2.getDescription(false)); +// } else { +// return 0; +// } } else{ return 0; } @@ -703,11 +705,13 @@ public class TaskListView extends ViewPart { viewer.addFilter(priorityFilter); 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); - } + + // XXX refactored +// if (MylarTasksPlugin.getDefault().refreshOnStartUpEnabled()) { +// refresh.setShowProgress(false); +// refresh.run(); +// refresh.setShowProgress(true); +// } viewer.refresh(); } @@ -801,13 +805,15 @@ public class TaskListView extends ViewPart { } else { event.data = "null"; } - } else if (selection.getFirstElement() instanceof BugzillaHit) { - if (!selection.isEmpty()) { - event.data = "" + ((BugzillaHit) selection.getFirstElement()).getHandle(); - } else { - event.data = "null"; - } - } + } + // XXX refactored +// else if (selection.getFirstElement() instanceof BugzillaHit) { +// if (!selection.isEmpty()) { +// event.data = "" + ((BugzillaHit) selection.getFirstElement()).getHandle(); +// } else { +// event.data = "null"; +// } +// } } public void dragFinished(DragSourceEvent event) { @@ -846,25 +852,27 @@ public class TaskListView extends ViewPart { viewer.setSelection(null); viewer.refresh(); return true; - } else if (selectedObject instanceof BugzillaHit) { - BugzillaHit bh = (BugzillaHit) selectedObject; - if (getCurrentTarget() instanceof TaskCategory) { - TaskCategory cat = (TaskCategory) getCurrentTarget(); - if (bh.getAssociatedTask() != null) { - bh.getAssociatedTask().setCategory(cat); - cat.addTask(bh.getAssociatedTask()); - } else { - BugzillaTask bt = new BugzillaTask(bh); - bh.setAssociatedTask(bt); - bt.setCategory(cat); - cat.addTask(bt); - MylarTasksPlugin.getTaskListManager().getTaskList().addToBugzillaTaskRegistry(bt); - } - viewer.setSelection(null); - viewer.refresh(); - return true; - } } + // XXX refactored +// else if (selectedObject instanceof BugzillaHit) { +// BugzillaHit bh = (BugzillaHit) selectedObject; +// if (getCurrentTarget() instanceof TaskCategory) { +// TaskCategory cat = (TaskCategory) getCurrentTarget(); +// if (bh.getAssociatedTask() != null) { +// bh.getAssociatedTask().setCategory(cat); +// cat.addTask(bh.getAssociatedTask()); +// } else { +// BugzillaTask bt = new BugzillaTask(bh); +// bh.setAssociatedTask(bt); +// bt.setCategory(cat); +// cat.addTask(bt); +// MylarTasksPlugin.getTaskListManager().getTaskList().addToBugzillaTaskRegistry(bt); +// } +// viewer.setSelection(null); +// viewer.refresh(); +// return true; +// } +// } return false; } @@ -879,13 +887,15 @@ public class TaskListView extends ViewPart { } else { return false; } - } else if (selectedObject instanceof BugzillaHit) { - if (getCurrentTarget() != null && getCurrentTarget() instanceof TaskCategory) { - return true; - } else { - return false; - } - } + } + // XXX refactored +// else if (selectedObject instanceof BugzillaHit) { +// if (getCurrentTarget() != null && getCurrentTarget() instanceof TaskCategory) { +// return true; +// } else { +// return false; +// } +// } return TextTransfer.getInstance().isSupportedType(transferType); } @@ -931,104 +941,108 @@ public class TaskListView extends ViewPart { manager.add(incompleteTask); // manager.add(new Separator()); manager.add(createTask); - manager.add(createBugzillaTask); +// manager.add(createBugzillaTask); // manager.add(rename); manager.add(delete); manager.add(clearSelectedTaskscapeAction); - manager.add(moveTaskToRoot); - manager.add(refreshQuery); +// manager.add(moveTaskToRoot); +// manager.add(refreshQuery); manager.add(new Separator()); MenuManager subMenuManager = new MenuManager("Choose Highlighter"); final Object selectedObject = ((IStructuredSelection)viewer.getSelection()).getFirstElement(); - for (Iterator<Highlighter> it = MylarUiPlugin.getDefault().getHighlighters().iterator(); it.hasNext();) { - final Highlighter highlighter = it.next(); - if (selectedObject instanceof Task){ - Action action = new Action() { - - @Override - public void run() { - Task task = (Task)selectedObject; - MylarUiPlugin.getDefault().setHighlighterMapping(task.getHandle(), highlighter.getName()); - TaskListView.this.viewer.refresh(); - MylarPlugin.getTaskscapeManager().notifyPostPresentationSettingsChange(ITaskscapeListener.UpdateKind.HIGHLIGHTER); -// taskscapeComponent.getTableViewer().refresh(); - } - }; - if (highlighter.isGradient()) { - action.setImageDescriptor(new HighlighterImageDescriptor(highlighter.getBase(), highlighter.getLandmarkColor())); - } else { - action.setImageDescriptor(new HighlighterImageDescriptor(highlighter.getLandmarkColor(), highlighter.getLandmarkColor())); - } - action.setText(highlighter.toString()); - subMenuManager.add(action); - } else { -// showMessage("Select task before choosing highlighter"); - } - } + + // XXX refactored +// for (Iterator<Highlighter> it = MylarUiPlugin.getDefault().getHighlighters().iterator(); it.hasNext();) { +// final Highlighter highlighter = it.next(); +// if (selectedObject instanceof Task){ +// Action action = new Action() { +// +// @Override +// public void run() { +// Task task = (Task)selectedObject; +// MylarUiPlugin.getDefault().setHighlighterMapping(task.getHandle(), highlighter.getName()); +// TaskListView.this.viewer.refresh(); +// MylarPlugin.getTaskscapeManager().notifyPostPresentationSettingsChange(ITaskscapeListener.UpdateKind.HIGHLIGHTER); +//// taskscapeComponent.getTableViewer().refresh(); +// } +// }; +// if (highlighter.isGradient()) { +// action.setImageDescriptor(new HighlighterImageDescriptor(highlighter.getBase(), highlighter.getLandmarkColor())); +// } else { +// action.setImageDescriptor(new HighlighterImageDescriptor(highlighter.getLandmarkColor(), highlighter.getLandmarkColor())); +// } +// action.setText(highlighter.toString()); +// subMenuManager.add(action); +// } else { +//// showMessage("Select task before choosing highlighter"); +// } +// } manager.add(subMenuManager); manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); updateActionEnablement(selectedObject); } private void updateActionEnablement(Object sel){ - if(sel != null && sel instanceof ITaskListElement){ - if(sel instanceof BugzillaHit){ - BugzillaTask task = ((BugzillaHit)sel).getAssociatedTask(); - if(task == null){ - clearSelectedTaskscapeAction.setEnabled(false); - } else { - clearSelectedTaskscapeAction.setEnabled(true); - } - completeTask.setEnabled(false); - incompleteTask.setEnabled(false); - moveTaskToRoot.setEnabled(false); - delete.setEnabled(false); - refreshQuery.setEnabled(false); - } else if(sel instanceof BugzillaTask){ - clearSelectedTaskscapeAction.setEnabled(true); - completeTask.setEnabled(false); - incompleteTask.setEnabled(false); - moveTaskToRoot.setEnabled(true); - delete.setEnabled(true); - refreshQuery.setEnabled(false); - } else if(sel instanceof AbstractCategory){ - clearSelectedTaskscapeAction.setEnabled(false); - completeTask.setEnabled(false); - incompleteTask.setEnabled(false); - moveTaskToRoot.setEnabled(false); - delete.setEnabled(true); - if (sel instanceof BugzillaQueryCategory) { - refreshQuery.setEnabled(true); - } else { - refreshQuery.setEnabled(false); - } - //delete.setEnabled(true); - } else { - clearSelectedTaskscapeAction.setEnabled(true); - completeTask.setEnabled(true); - incompleteTask.setEnabled(true); - moveTaskToRoot.setEnabled(true); - delete.setEnabled(true); - refreshQuery.setEnabled(false); - } - }else { - clearSelectedTaskscapeAction.setEnabled(false); - completeTask.setEnabled(false); - incompleteTask.setEnabled(false); - moveTaskToRoot.setEnabled(false); - delete.setEnabled(false); - refreshQuery.setEnabled(false); - } + // XXX refactored + throw new RuntimeException("unimplemented"); +// if(sel != null && sel instanceof ITaskListElement){ +// if(sel instanceof BugzillaHit){ +// BugzillaTask task = ((BugzillaHit)sel).getAssociatedTask(); +// if(task == null){ +// clearSelectedTaskscapeAction.setEnabled(false); +// } else { +// clearSelectedTaskscapeAction.setEnabled(true); +// } +// completeTask.setEnabled(false); +// incompleteTask.setEnabled(false); +// moveTaskToRoot.setEnabled(false); +// delete.setEnabled(false); +// refreshQuery.setEnabled(false); +// } else if(sel instanceof BugzillaTask){ +// clearSelectedTaskscapeAction.setEnabled(true); +// completeTask.setEnabled(false); +// incompleteTask.setEnabled(false); +// moveTaskToRoot.setEnabled(true); +// delete.setEnabled(true); +// refreshQuery.setEnabled(false); +// } else if(sel instanceof AbstractCategory){ +// clearSelectedTaskscapeAction.setEnabled(false); +// completeTask.setEnabled(false); +// incompleteTask.setEnabled(false); +// moveTaskToRoot.setEnabled(false); +// delete.setEnabled(true); +// if (sel instanceof BugzillaQueryCategory) { +// refreshQuery.setEnabled(true); +// } else { +// refreshQuery.setEnabled(false); +// } +// //delete.setEnabled(true); +// } else { +// clearSelectedTaskscapeAction.setEnabled(true); +// completeTask.setEnabled(true); +// incompleteTask.setEnabled(true); +// moveTaskToRoot.setEnabled(true); +// delete.setEnabled(true); +// refreshQuery.setEnabled(false); +// } +// } else { +// clearSelectedTaskscapeAction.setEnabled(false); +// completeTask.setEnabled(false); +// incompleteTask.setEnabled(false); +// moveTaskToRoot.setEnabled(false); +// delete.setEnabled(false); +// refreshQuery.setEnabled(false); +// } } private void fillLocalToolBar(IToolBarManager manager) { manager.add(createTask); manager.add(createCategory); manager.add(new Separator()); - manager.add(createBugzillaTask); - manager.add(createBugzillaQueryCategory); - manager.add(refresh); - manager.add(new Separator()); +// manager.add(createBugzillaTask); +// manager.add(createBugzillaQueryCategory); +// manager.add(refresh); +// manager.add(new Separator()); manager.add(filterCompleteTask); // manager.add(filterInCompleteTask); manager.add(filterOnPriority); @@ -1039,22 +1053,19 @@ public class TaskListView extends ViewPart { * */ private void makeActions() { - refresh = new RefreshBugzillaReportsAction(this); - createTask = new CreateTaskAction(this); + createTask = new CreateTaskAction(this); createCategory = new CreateCategoryAction(this); - createBugzillaQueryCategory = new CreateBugzillaQueryCategoryAction(this); - createBugzillaTask = new CreateBugzillaTaskAction(this); + delete = new DeleteAction(this); completeTask = new MarkTaskCompleteAction(this); incompleteTask = new MarkTaskIncompleteAction(this); // rename = new RenameAction(); clearSelectedTaskscapeAction = new ClearContextAction(this); - moveTaskToRoot = new MoveTaskToRootAction(this); +// moveTaskToRoot = new MoveTaskToRootAction(this); doubleClickAction = new OpenTaskEditorAction(this); filterCompleteTask = new FilterCompletedTasksAction(this); // filterInCompleteTask = new FilterIncompleteTasksAction(); filterOnPriority = new PriorityDropDownAction(); - refreshQuery = new RefreshBugzillaAction(this); } /** @@ -1086,9 +1097,11 @@ public class TaskListView extends ViewPart { public void closeTaskEditors(ITask task, IWorkbenchPage page) throws LoginException, IOException{ IEditorInput input = null; - if (task instanceof BugzillaTask) { - input = new BugzillaTaskEditorInput((BugzillaTask)task); - } else if (task instanceof Task) { + // XXX refactored +// if (task instanceof BugzillaTask) { +// input = new BugzillaTaskEditorInput((BugzillaTask)task); +// } else + if (task instanceof Task) { input = new TaskEditorInput((Task) task); } IEditorPart editor = page.findEditor(input); @@ -1101,9 +1114,10 @@ public class TaskListView extends ViewPart { public void refreshChildren(List<ITask> children) { if (children != null) { for (ITask child : children) { - if (child instanceof BugzillaTask) { - ((BugzillaTask)child).refresh(); - } + // XXX refactored +// if (child instanceof BugzillaTask) { +// ((BugzillaTask)child).refresh(); +// } } } } diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/util/DefaultTaskListExternalizer.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/util/DefaultTaskListExternalizer.java new file mode 100644 index 000000000..9170dcace --- /dev/null +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/util/DefaultTaskListExternalizer.java @@ -0,0 +1,208 @@ +/******************************************************************************* + * 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.util; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.mylar.core.MylarPlugin; +import org.eclipse.mylar.tasks.AbstractCategory; +import org.eclipse.mylar.tasks.ITask; +import org.eclipse.mylar.tasks.Task; +import org.eclipse.mylar.tasks.TaskCategory; +import org.eclipse.mylar.tasks.TaskList; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +/** + * @author Mik Kersten and Ken Sueda + */ +public class DefaultTaskListExternalizer implements ITaskListExternalizer { + + public static final String LABEL = "Label"; + public static final String HANDLE = "Handle"; + public static final String TAG_CATEGORY = "Category"; + public static final String TAG_TASK = "Task"; + public static final String TAG_TASK_CATEGORY = "Task" + TAG_CATEGORY; + + public static final String LINK = "Link"; + public static final String ESTIMATED = "Estimated"; + public static final String ELAPSED = "Elapsed"; + public static final String NOTES = "Notes"; + public static final String BUGZILLA = "Bugzilla"; + public static final String ACTIVE = "Active"; + public static final String COMPLETE = "Complete"; + public static final String PRIORITY = "Priority"; + public static final String PATH = "Path"; + public static final String FALSE = "false"; + public static final String TRUE = "true"; + public static final String NAME = "Name"; + + private List<ITaskListExternalizer> externalizers = new ArrayList<ITaskListExternalizer>(); + + void setExternalizers(List<ITaskListExternalizer> externalizers) { + this.externalizers = externalizers; + } + + public boolean canCreateElementFor(AbstractCategory category) { + return category instanceof TaskCategory; + } + + public Element createCategoryElement(AbstractCategory category, Document doc, Element parent) { + Element node = doc.createElement(getCategoryTagName()); + node.setAttribute(NAME, category.getDescription(false)); + + for (ITask t : ((TaskCategory)category).getChildren()) { + try { + createTaskElement(t, doc, node); + } catch (Exception e) { + MylarPlugin.log(e, e.getMessage()); + } + + } + parent.appendChild(node); + return node; + } + + public boolean canCreateElementFor(ITask task) { + return true; + } + + public Element createTaskElement(ITask task, Document doc, Element parent) { + Element node = doc.createElement(getTaskTagName()); + node.setAttribute(PATH, task.getPath()); + node.setAttribute(LABEL, task.getLabel()); + node.setAttribute(HANDLE, task.getHandle()); + node.setAttribute(PRIORITY, task.getPriority()); + + if (task.isCompleted()) { + node.setAttribute(COMPLETE, TRUE); + } else { + node.setAttribute(COMPLETE, FALSE); + } + if (task.isActive()) { + node.setAttribute(ACTIVE, TRUE); + } else { + node.setAttribute(ACTIVE, FALSE); + } + node.setAttribute(BUGZILLA, FALSE); // TODO: this is not great + + node.setAttribute(NOTES, task.getNotes()); + node.setAttribute(ELAPSED, task.getElapsedTime()); + node.setAttribute(ESTIMATED, task.getEstimatedTime()); + List<String> rl = task.getRelatedLinks().getLinks(); + int i = 0; + for (String link : rl) { + node.setAttribute(LINK+i, link); + i++; + } + + for (ITask t : task.getChildren()) { + createTaskElement(t, doc, node); + } + parent.appendChild(node); + return node; + } + + public boolean canReadCategory(Node node) { + return node.getNodeName().equals(getCategoryTagName()); + } + + public void readCategory(Node node, TaskList tlist) { + Element element = (Element) node; + TaskCategory category = new TaskCategory(element.getAttribute("Name")); + tlist.addCategory(category); + NodeList list = node.getChildNodes(); + for (int i = 0; i < list.getLength(); i++) { + Node child = list.item(i); + boolean read = false; + for (ITaskListExternalizer externalizer : externalizers) { + if (externalizer.canReadTask(child)) { + category.addTask(externalizer.readTask(child, tlist, category, null)); + read = true; + } + } + if (!read) category.addTask(readTask(child, tlist, category, null)); + } + } + + public boolean canReadTask(Node node) { + return node.getNodeName().equals(getTaskTagName()); + } + + public ITask readTask(Node node, TaskList tlist, AbstractCategory category, ITask parent) { + Element element = (Element) node; + String handle = element.getAttribute(HANDLE); + String label = element.getAttribute(LABEL); + Task task = new Task(handle, label); + readTaskInfo(task, tlist, element, category, parent); + return task; + } + + protected void readTaskInfo(ITask task, TaskList tlist, Element element, AbstractCategory category, ITask parent) { + task.setPriority(element.getAttribute(PRIORITY)); + task.setPath(element.getAttribute(PATH)); + + if (element.getAttribute(ACTIVE).compareTo(TRUE) == 0) { + task.setActive(true); + tlist.setActive(task, true); + } else { + task.setActive(false); + } + if (element.getAttribute(COMPLETE).compareTo(TRUE) == 0) { + task.setCompleted(true); + } else { + task.setCompleted(false); + } + if (element.hasAttribute(NOTES)) { + task.setNotes(element.getAttribute(NOTES)); + } else { + task.setNotes(""); + } + if (element.hasAttribute(ELAPSED)) { + task.setElapsedTime(element.getAttribute(ELAPSED)); + } else { + task.setElapsedTime(""); + } + if (element.hasAttribute(ESTIMATED)) { + task.setEstimatedTime(element.getAttribute(ESTIMATED)); + } else { + task.setEstimatedTime(""); + } + int i = 0; + while (element.hasAttribute(LINK+i)) { + task.getRelatedLinks().add(element.getAttribute(LINK+i)); + i++; + } + if (category != null) { + task.setCategory((TaskCategory) category); + } else { + task.setCategory(null); + } + task.setParent(parent); + NodeList list = element.getChildNodes(); + for (int j = 0; j < list.getLength(); j++) { + Node child = list.item(j); + task.addSubTask(readTask(child, tlist, null, task)); + } + } + + public String getCategoryTagName() { + return TAG_TASK_CATEGORY; + } + + public String getTaskTagName() { + return TAG_TASK; + } +} diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/util/ITaskListExternalizer.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/util/ITaskListExternalizer.java new file mode 100644 index 000000000..04e42fe5d --- /dev/null +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/util/ITaskListExternalizer.java @@ -0,0 +1,53 @@ +/******************************************************************************* + * 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.util; + +import org.eclipse.mylar.tasks.AbstractCategory; +import org.eclipse.mylar.tasks.ITask; +import org.eclipse.mylar.tasks.TaskList; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; + +/** + * @author Mik Kersten and Ken Sueda + * + * TODO: consider merging tasks and categories + */ +public interface ITaskListExternalizer { + + public abstract String getCategoryTagName(); + + public abstract String getTaskTagName(); + + public abstract boolean canCreateElementFor(AbstractCategory category); + + /** + * @return the element that was created, null if failed + */ + public abstract Element createCategoryElement(AbstractCategory category, Document doc, Element parent); + + public abstract boolean canCreateElementFor(ITask task); + + /** + * @return the element that was created, null if failed + */ + public abstract Element createTaskElement(ITask task, Document doc, Element parent); + + public abstract boolean canReadCategory(Node node); + + public abstract void readCategory(Node node, TaskList tlist); + + public abstract boolean canReadTask(Node node); + + public abstract ITask readTask(Node node, TaskList tlist, AbstractCategory category, ITask parent); +} diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/util/TaskListExternalizer.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/util/TaskListExternalizer.java new file mode 100644 index 000000000..78de68836 --- /dev/null +++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/util/TaskListExternalizer.java @@ -0,0 +1,591 @@ + +/******************************************************************************* + * 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.util; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.List; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.transform.Result; +import javax.xml.transform.Source; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerConfigurationException; +import javax.xml.transform.TransformerException; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.TransformerFactoryConfigurationError; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; + +import org.eclipse.mylar.core.MylarPlugin; +import org.eclipse.mylar.tasks.AbstractCategory; +import org.eclipse.mylar.tasks.ITask; +import org.eclipse.mylar.tasks.MylarTasksPlugin; +import org.eclipse.mylar.tasks.TaskList; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.SAXException; + +/** + * @author Mik Kersten and Ken Sueda + */ +public class TaskListExternalizer { + + private List<ITaskListExternalizer> externalizers = new ArrayList<ITaskListExternalizer>(); + private ITaskListExternalizer defaultExternalizer = new DefaultTaskListExternalizer(); + + private String readVersion = ""; + + public void addExternalizer(ITaskListExternalizer externalizer) { + externalizers.add(externalizer); +// System.err.println(">>>>>>>>> " + MylarTasksPlugin.getTaskListManager().getTaskListFile()); +// readTaskList(MylarTasksPlugin.getTaskListManager().getTaskList(), MylarTasksPlugin.getTaskListManager().getTaskListFile()); + } + + public void removeExternalizer(ITaskListExternalizer externalizer) { + externalizers.remove(externalizer); + } + + public void writeTaskList(TaskList tlist, File outFile) { + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + DocumentBuilder db; + Document doc = null; + + try { + db = dbf.newDocumentBuilder(); + doc = db.newDocument(); + } catch (ParserConfigurationException e) { + MylarPlugin.log(e, "could not create document"); + e.printStackTrace(); + } + + Element root = doc.createElement("TaskList"); + root.setAttribute("Version", "1.0.1"); + + // XXX refactored +// writeBugzillaRegistry(tlist.getBugzillaTaskRegistry(), doc, root); + + // iterate through each subtask and externalize those + // + for (AbstractCategory category : tlist.getCategories()) { + Element element = null; + for (ITaskListExternalizer externalizer : externalizers) { + if (externalizer.canCreateElementFor(category)) element = externalizer.createCategoryElement(category, doc, root); + } + if (element == null) defaultExternalizer.createCategoryElement(category, doc, root); +// +// if (cat instanceof TaskCategory) { +// writeTaskCategory((TaskCategory)cat, doc, root); +// } else if (cat instanceof BugzillaQueryCategory) { +// writeQueryCategory((BugzillaQueryCategory)cat, doc, root); +// } + } + for (ITask task : tlist.getRootTasks()) { + try { + Element element = null; + for (ITaskListExternalizer externalizer : externalizers) { + if (externalizer.canCreateElementFor(task)) element = externalizer.createTaskElement(task, doc, root); + } + if (element == null) defaultExternalizer.createTaskElement(task, doc, root); + }catch (Exception e) { + MylarPlugin.log(e, e.getMessage()); + } + } + doc.appendChild(root); + writeDOMtoFile(doc, outFile); + return; + } + + // XXX refactored +// private static void writeBugzillaRegistry(Map<String, BugzillaTask> bugzillaTaskRegistry, Document doc, Element parent) { +// Element node = doc.createElement("BugzillaTaskRegistry"); +// +// for (BugzillaTask t : bugzillaTaskRegistry.values()) { +// try { +// writeTask(t, doc, node); +// } catch (Exception e) { +// MylarPlugin.log(e, e.getMessage()); +// } +// +// } +// parent.appendChild(node); +// } + + /** + * Writes an XML file from a DOM. + * + * doc - the document to write + * file - the file to be written to + */ + private void writeDOMtoFile(Document doc, File file) { + try { + // A file output stream is an output stream for writing data to a File + // + OutputStream outputStream = new FileOutputStream(file); + writeDOMtoStream(doc, outputStream); + outputStream.flush(); + outputStream.close(); + } catch (Exception fnfe) { + MylarPlugin.log(fnfe, "Tasklist could not be found"); + } + } + + /** + * Writes the provided XML document out to the specified output stream. + * + * doc - the document to be written + * outputStream - the stream to which the document is to be written + */ + private void writeDOMtoStream(Document doc, OutputStream outputStream) { + // Prepare the DOM document for writing + // DOMSource - Acts as a holder for a transformation Source tree in the + // form of a Document Object Model (DOM) tree + // + Source source = new DOMSource(doc); + + // StreamResult - Acts as an holder for a XML transformation result + // Prepare the output stream + // + Result result = new StreamResult(outputStream); + + // An instance of this class can be obtained with the + // TransformerFactory.newTransformer method. This instance may + // then be used to process XML from a variety of sources and write + // the transformation output to a variety of sinks + // + + Transformer xformer = null; + try { + xformer = TransformerFactory.newInstance().newTransformer(); + //Transform the XML Source to a Result + // + xformer.transform(source, result); + } catch (TransformerConfigurationException e) { + e.printStackTrace(); + } catch (TransformerFactoryConfigurationError e) { + e.printStackTrace(); + } catch (TransformerException e1) { + e1.printStackTrace(); + } + } + +// private void writeTask(ITask task, Document doc, Element parent) { +// +// } + + public void readTaskList(TaskList tlist, File inFile) { + try { + // parse file + // + Document doc = openAsDOM(inFile); + + // read root node to get version number + // + Element root = doc.getDocumentElement(); + readVersion = root.getAttribute("Version"); + + if (readVersion.equals("1.0.0")) { + MylarPlugin.log("version: " + readVersion + " not supported", this); +// NodeList list = root.getChildNodes(); +// for (int i = 0; i < list.getLength(); i++) { +// Node child = list.item(i); +// readTasksToNewFormat(child, tlist); +// //tlist.addRootTask(readTaskAndSubTasks(child, null, tlist)); +// } + } else { + NodeList list = root.getChildNodes(); + for (int i = 0; i < list.getLength(); i++) { + Node child = list.item(i); + boolean wasRead = false; + if (child.getNodeName().endsWith(DefaultTaskListExternalizer.TAG_CATEGORY)) { + for (ITaskListExternalizer externalizer : externalizers) { + if (externalizer.canReadCategory(child)) { + externalizer.readCategory(child, tlist); + wasRead = true; + break; + } + } + if (!wasRead) defaultExternalizer.readCategory(child, tlist); + } else { + for (ITaskListExternalizer externalizer : externalizers) { + if (externalizer.canReadTask(child)) { + tlist.addRootTask(externalizer.readTask(child, tlist, null, null)); + wasRead = true; + break; + } + } + if (!wasRead) tlist.addRootTask(defaultExternalizer.readTask(child, tlist, null, null)); + } + +// if (child.getNodeName().equals("Category") || +// child.getNodeName().equals("TaskCategory")) { +// readTaskCategory(child, tlist); +//// } else if (child.getNodeName().equals("BugzillaTaskRegistry")) { +//// readBugzillaRegistry(child, tlist); +// } else if (child.getNodeName().equals("QueryCategory")) { +// readQueryCategory(child, tlist); +// } else { +// tlist.addRootTask(readTask(child, tlist, null, null)); +// } + } + } + } catch (Exception e) { + String name = inFile.getAbsolutePath(); + name = name.substring(0, name.lastIndexOf('.')) + "-save.xml"; + inFile.renameTo(new File(name)); + MylarPlugin.log(e, "Could not read task list"); + } + } + + // XXX refactored +// private void readBugzillaRegistry(Node node, TaskList tlist) { +// NodeList list = node.getChildNodes(); +// for (int i = 0; i < list.getLength(); i++) { +// Node child = list.item(i); +// ITask task = readTask(child, tlist, null, null); +// if(task instanceof BugzillaTask){ +// tlist.addToBugzillaTaskRegistry((BugzillaTask)task); +// } +// } +// } + + /** + * Opens the specified XML file and parses it into a DOM Document. + * + * Filename - the name of the file to open + * Return - the Document built from the XML file + * Throws - XMLException if the file cannot be parsed as XML + * - IOException if the file cannot be opened + */ + private Document openAsDOM(File inputFile) throws IOException { + + // A factory API that enables applications to obtain a parser + // that produces DOM object trees from XML documents + // + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + + // Using DocumentBuilder, obtain a Document from XML file. + // + DocumentBuilder builder = null; + Document document = null; + try { + // create new instance of DocumentBuilder + // + builder = factory.newDocumentBuilder(); + } catch (ParserConfigurationException pce) { + inputFile.renameTo(new File(inputFile.getName() + "save.xml")); + MylarPlugin.log(pce, "Failed to load XML file"); + } + try { + // Parse the content of the given file as an XML document + // and return a new DOM Document object. Also throws IOException + document = builder.parse(inputFile); + } catch (SAXException se) { + inputFile.renameTo(new File(inputFile.getName() + "save.xml")); + MylarPlugin.log(se, "Failed to parse XML file"); + } + return document; + } + +// private static ITask readTaskAndSubTasks(Node node, ITask root, TaskList tlist) { +// //extract node and create new sub task +// // +// Element e = (Element) node; +// ITask t; +// String handle = ""; +// if (e.hasAttribute("ID")) { +// handle = e.getAttribute("ID"); +// } else { +// handle = e.getAttribute("Handle"); +// } +// +// String label = e.getAttribute("Label"); +// String priority = e.getAttribute("Priority"); +// +// if (e.getAttribute("Bugzilla").compareTo("true") == 0) { +// t = new BugzillaTask(handle, label, true); +// BugzillaTask bt = (BugzillaTask) t; +// bt.setState(BugTaskState.FREE); +// bt.setLastRefresh(new Date(new Long(e.getAttribute("LastDate")) +// .longValue())); +// if (e.getAttribute("Dirty").compareTo("true") == 0) { +// bt.setDirty(true); +// } else { +// bt.setDirty(false); +// } +// if (bt.readBugReport() == false) { +// MylarPlugin.log("Failed to read bug report", null); +// } +// } else { +// t = new Task(handle, label); +// } +// t.setPriority(priority); +// t.setPath(e.getAttribute("Path")); +// +// if (e.getAttribute("Active").compareTo("true") == 0) { +// t.setActive(true); +// tlist.setActive(t, true); +// } else { +// t.setActive(false); +// } +// +// if (e.getAttribute("Complete").compareTo("true") == 0) { +// t.setCompleted(true); +// } else { +// t.setCompleted(false); +// } +// if (e.getAttribute("IsCategory").compareTo("true") == 0) { +// t.setIsCategory(true); +// } else { +// t.setIsCategory(false); +// } +// +// if (e.hasAttribute("Notes")) { +// t.setNotes(e.getAttribute("Notes")); +// } else { +// t.setNotes(""); +// } +// if (e.hasAttribute("Elapsed")) { +// t.setElapsedTime(e.getAttribute("Elapsed")); +// } else { +// t.setElapsedTime(""); +// } +// if (e.hasAttribute("Estimated")) { +// t.setEstimatedTime(e.getAttribute("Estimated")); +// } else { +// t.setEstimatedTime(""); +// } +// +// int i = 0; +// while (e.hasAttribute("link"+i)) { +// t.getRelatedLinks().add(e.getAttribute("link"+i)); +// i++; +// } +// +// if (!readVersion.equals("1.0.0")) { +// // for newer revisions +// } +// +// i = 0; +// NodeList list = e.getChildNodes(); +// for (i = 0; i < list.getLength(); i++) { +// Node child = list.item(i); +// t.addSubTask(readTaskAndSubTasks(child, t, tlist)); +// } +// if (root != null) { +// t.setParent(root); +// } +// return t; +// } + +// private void readTaskCategory(Node node, TaskList tlist) { +// Element e = (Element) node; +// TaskCategory cat = new TaskCategory(e.getAttribute("Name")); +// tlist.addCategory(cat); +// NodeList list = node.getChildNodes(); +// for (int i = 0; i < list.getLength(); i++) { +// Node child = list.item(i); +// cat.addTask(readTask(child, tlist, cat, null)); +// } +// } + + +// private ITask readTask(Node node, TaskList tlist, TaskCategory cat, ITask parent) { +// Element e = (Element) node; +// ITask t; +// String handle = e.getAttribute("Handle"); +// String label = e.getAttribute("Label"); +// String priority = e.getAttribute("Priority"); +// +// +// } else { +// t = new Task(handle, label); +// } +// t.setPriority(priority); +// t.setPath(e.getAttribute("Path")); +// +// if (e.getAttribute("Active").compareTo("true") == 0) { +// t.setActive(true); +// tlist.setActive(t, true); +// } else { +// t.setActive(false); +// } +// if (e.getAttribute("Complete").compareTo("true") == 0) { +// t.setCompleted(true); +// } else { +// t.setCompleted(false); +// } +// if (e.hasAttribute("Notes")) { +// t.setNotes(e.getAttribute("Notes")); +// } else { +// t.setNotes(""); +// } +// if (e.hasAttribute("Elapsed")) { +// t.setElapsedTime(e.getAttribute("Elapsed")); +// } else { +// t.setElapsedTime(""); +// } +// if (e.hasAttribute("Estimated")) { +// t.setEstimatedTime(e.getAttribute("Estimated")); +// } else { +// t.setEstimatedTime(""); +// } +// +// int i = 0; +// while (e.hasAttribute("link"+i)) { +// t.getRelatedLinks().add(e.getAttribute("link"+i)); +// i++; +// } +// t.setCategory(cat); +// t.setParent(parent); +// NodeList list = e.getChildNodes(); +// for (i = 0; i < list.getLength(); i++) { +// Node child = list.item(i); +// t.addSubTask(readTask(child, tlist, null, t)); +// } +// return t; +// } + +// private void readTasksToNewFormat(Node node, TaskList tlist) { +// Element e = (Element) node; +// ITask t; +// String handle = e.getAttribute("Handle"); +// String label = e.getAttribute("Label"); +// +// if (e.getAttribute("IsCategory").compareTo("true") == 0) { +// TaskCategory c = new TaskCategory(label); +// NodeList list = e.getChildNodes(); +// for (int i = 0; i < list.getLength(); i++) { +// Node child = list.item(i); +// readSubTasksToNewFormat(child, tlist, c); +// } +// tlist.addCategory(c); +// } else { +// String priority = e.getAttribute("Priority"); +// if (e.getAttribute("Bugzilla").compareTo("true") == 0) { +// t = new BugzillaTask(handle, label, true); +// BugzillaTask bt = (BugzillaTask) t; +// bt.setState(BugTaskState.FREE); +// bt.setLastRefresh(new Date(new Long(e.getAttribute("LastDate")) +// .longValue())); +// if (e.getAttribute("Dirty").compareTo("true") == 0) { +// bt.setDirty(true); +// } else { +// bt.setDirty(false); +// } +// if (bt.readBugReport() == false) { +// MylarPlugin.log("Failed to read bug report", null); +// } +// } else { +// t = new Task(handle, label); +// } +// t.setPriority(priority); +// t.setPath(e.getAttribute("Path")); +// t.setNotes(e.getAttribute("Notes")); +// t.setElapsedTime(e.getAttribute("Elapsed")); +// t.setEstimatedTime(e.getAttribute("Estimated")); +// +// if (e.getAttribute("Active").compareTo("true") == 0) { +// t.setActive(true); +// tlist.setActive(t, true); +// } else { +// t.setActive(false); +// } +// if (e.getAttribute("Complete").compareTo("true") == 0) { +// t.setCompleted(true); +// } else { +// t.setCompleted(false); +// } +// +// int i = 0; +// while (e.hasAttribute("link" + i)) { +// t.getRelatedLinks().add(e.getAttribute("link" + i)); +// i++; +// } +// tlist.addRootTask(t); +// i = 0; +// NodeList list = e.getChildNodes(); +// for (i = 0; i < list.getLength(); i++) { +// Node child = list.item(i); +// readSubTasksToNewFormat(child, tlist, null); +// } +// } +// } +// private void readSubTasksToNewFormat(Node node, TaskList tlist, TaskCategory cat) { +// Element e = (Element) node; +// ITask t; +// String handle = e.getAttribute("Handle"); +// String label = e.getAttribute("Label"); +// String priority = e.getAttribute("Priority"); +// if (e.getAttribute("Bugzilla").compareTo("true") == 0) { +// t = new BugzillaTask(handle, label, true); +// BugzillaTask bt = (BugzillaTask) t; +// bt.setState(BugTaskState.FREE); +// bt.setLastRefresh(new Date(new Long(e.getAttribute("LastDate")) +// .longValue())); +// if (e.getAttribute("Dirty").compareTo("true") == 0) { +// bt.setDirty(true); +// } else { +// bt.setDirty(false); +// } +// if (bt.readBugReport() == false) { +// MylarPlugin.log("Failed to read bug report", null); +// } +// } else { +// t = new Task(handle, label); +// } +// t.setPriority(priority); +// t.setPath(e.getAttribute("Path")); +// t.setNotes(e.getAttribute("Notes")); +// t.setElapsedTime(e.getAttribute("Elapsed")); +// t.setEstimatedTime(e.getAttribute("Estimated")); +// +// if (e.getAttribute("Active").compareTo("true") == 0) { +// t.setActive(true); +// tlist.setActive(t, true); +// } else { +// t.setActive(false); +// } +// if (e.getAttribute("Complete").compareTo("true") == 0) { +// t.setCompleted(true); +// } else { +// t.setCompleted(false); +// } +// +// int i = 0; +// while (e.hasAttribute("link" + i)) { +// t.getRelatedLinks().add(e.getAttribute("link" + i)); +// i++; +// } +// if (cat == null) { +// tlist.addRootTask(t); +// } else { +// cat.addTask(t); +// t.setCategory(cat); +// } +// +// i = 0; +// NodeList list = e.getChildNodes(); +// for (i = 0; i < list.getLength(); i++) { +// Node child = list.item(i); +// readSubTasksToNewFormat(child, tlist, cat); +// } +// } +} + diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/util/XmlUtil.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/util/XmlUtil.java deleted file mode 100644 index 541532f5c..000000000 --- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/util/XmlUtil.java +++ /dev/null @@ -1,712 +0,0 @@ -/******************************************************************************* - * 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 - *******************************************************************************/ -/* - * Created on Jan 17, 2005 - */ -package org.eclipse.mylar.tasks.util; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.util.Date; -import java.util.List; -import java.util.Map; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.transform.Result; -import javax.xml.transform.Source; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerConfigurationException; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.TransformerFactoryConfigurationError; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; - -import org.eclipse.mylar.core.MylarPlugin; -import org.eclipse.mylar.tasks.AbstractCategory; -import org.eclipse.mylar.tasks.BugzillaQueryCategory; -import org.eclipse.mylar.tasks.BugzillaTask; -import org.eclipse.mylar.tasks.ITask; -import org.eclipse.mylar.tasks.Task; -import org.eclipse.mylar.tasks.TaskCategory; -import org.eclipse.mylar.tasks.TaskList; -import org.eclipse.mylar.tasks.BugzillaTask.BugTaskState; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.SAXException; - - -/** - * @author Ken Sueda - */ -public class XmlUtil { - - private static String readVersion = ""; - - /** - * - * @param tlist - * @param outFile - */ - public static void writeTaskList(TaskList tlist, File outFile) { - DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); - DocumentBuilder db; - Document doc = null; - - try { - db = dbf.newDocumentBuilder(); - doc = db.newDocument(); - } catch (ParserConfigurationException e) { - e.printStackTrace(); - } - - Element root = doc.createElement("TaskList"); - root.setAttribute("Version", "1.0.1"); - - writeBugzillaRegistry(tlist.getBugzillaTaskRegistry(), doc, root); - - // iterate through each subtask and externalize those - // - for (AbstractCategory cat : tlist.getCategories()) { - if (cat instanceof TaskCategory) { - writeTaskCategory((TaskCategory)cat, doc, root); - } else if (cat instanceof BugzillaQueryCategory) { - writeQueryCategory((BugzillaQueryCategory)cat, doc, root); - } - } - for (ITask task : tlist.getRootTasks()) { - try { - writeTask(task, doc, root); - }catch (Exception e) { - MylarPlugin.log(e, e.getMessage()); - } - } - doc.appendChild(root); - writeDOMtoFile(doc, outFile); - return; - } - - private static void writeBugzillaRegistry(Map<String, BugzillaTask> bugzillaTaskRegistry, Document doc, Element parent) { - Element node = doc.createElement("BugzillaTaskRegistry"); - - for (BugzillaTask t : bugzillaTaskRegistry.values()) { - try { - writeTask(t, doc, node); - } catch (Exception e) { - MylarPlugin.log(e, e.getMessage()); - } - - } - parent.appendChild(node); - } - - /** - * Writes an XML file from a DOM. - * - * doc - the document to write - * file - the file to be written to - */ - private static void writeDOMtoFile(Document doc, File file) { - try { - // A file output stream is an output stream for writing data to a File - // - OutputStream outputStream = new FileOutputStream(file); - writeDOMtoStream(doc, outputStream); - outputStream.flush(); - outputStream.close(); - } catch (Exception fnfe) { - MylarPlugin.log(fnfe, "Tasklist could not be found"); - } - } - - /** - * Writes the provided XML document out to the specified output stream. - * - * doc - the document to be written - * outputStream - the stream to which the document is to be written - */ - private static void writeDOMtoStream(Document doc, OutputStream outputStream) { - // Prepare the DOM document for writing - // DOMSource - Acts as a holder for a transformation Source tree in the - // form of a Document Object Model (DOM) tree - // - Source source = new DOMSource(doc); - - // StreamResult - Acts as an holder for a XML transformation result - // Prepare the output stream - // - Result result = new StreamResult(outputStream); - - // An instance of this class can be obtained with the - // TransformerFactory.newTransformer method. This instance may - // then be used to process XML from a variety of sources and write - // the transformation output to a variety of sinks - // - - Transformer xformer = null; - try { - xformer = TransformerFactory.newInstance().newTransformer(); - //Transform the XML Source to a Result - // - xformer.transform(source, result); - } catch (TransformerConfigurationException e) { - e.printStackTrace(); - } catch (TransformerFactoryConfigurationError e) { - e.printStackTrace(); - } catch (TransformerException e1) { - e1.printStackTrace(); - } - } - -// /** -// * Method deprecated until subtasks are introduced again. -// * @param t -// * @param doc -// * @param root -// */ -// private static void writeTaskAndSubTasks(ITask t, Document doc, Element root) { -// -// // create node and set attributes -// // -// Element node = doc.createElement("Task"); -// node.setAttribute("Path", t.getPath()); -// node.setAttribute("Label", t.getLabel()); -// node.setAttribute("Handle", t.getHandle()); -// node.setAttribute("Priority", t.getPriority()); -// -// if (t.isCategory()) { -// node.setAttribute("IsCategory", "true"); -// } else { -// node.setAttribute("IsCategory", "false"); -// } -// if (t.isCompleted()) { -// node.setAttribute("Complete", "true"); -// } else { -// node.setAttribute("Complete", "false"); -// } -// if (t.isActive()) { -// node.setAttribute("Active", "true"); -// } else { -// node.setAttribute("Active", "false"); -// } -// if (t instanceof BugzillaTask) { -// BugzillaTask bt = (BugzillaTask) t; -// node.setAttribute("Bugzilla", "true"); -// node.setAttribute("LastDate", new Long(bt.getLastRefreshTime() -// .getTime()).toString()); -// if (bt.isDirty()) { -// node.setAttribute("Dirty", "true"); -// } else { -// node.setAttribute("Dirty", "false"); -// } -// bt.saveBugReport(false); -// } else { -// node.setAttribute("Bugzilla", "false"); -// } -// node.setAttribute("Notes", t.getNotes()); -// node.setAttribute("Elapsed", t.getElapsedTime()); -// node.setAttribute("Estimated", t.getEstimatedTime()); -// List<String> rl = t.getRelatedLinks().getLinks(); -// int i = 0; -// for (String link : rl) { -// node.setAttribute("link"+i, link); -// i++; -// } -// -// List<ITask> children = t.getChildren(); -// -// i = 0; -// for (i = 0; i < children.size(); i++) { -// writeTaskAndSubTasks(children.get(i), doc, node); -// } -// -// // append new node to root node -// // -// root.appendChild(node); -// return; -// } - - private static void writeTaskCategory(TaskCategory cat, Document doc, Element parent) { - Element node = doc.createElement("TaskCategory"); - node.setAttribute("Name", cat.getDescription(false)); - - for (ITask t : cat.getChildren()) { - try { - writeTask(t, doc, node); - } catch (Exception e) { - MylarPlugin.log(e, e.getMessage()); - } - - } - parent.appendChild(node); - } - - private static void writeQueryCategory(BugzillaQueryCategory cat, Document doc, Element parent) { - Element node = doc.createElement("QueryCategory"); - node.setAttribute("Description", cat.getDescription(false)); - node.setAttribute("URL", cat.getUrl()); - parent.appendChild(node); - } - - private static void writeTask(ITask task, Document doc, Element parent) { - Element node = doc.createElement("Task"); - node.setAttribute("Path", task.getPath()); - node.setAttribute("Label", task.getLabel()); - node.setAttribute("Handle", task.getHandle()); - node.setAttribute("Priority", task.getPriority()); - - if (task.isCompleted()) { - node.setAttribute("Complete", "true"); - } else { - node.setAttribute("Complete", "false"); - } - if (task.isActive()) { - node.setAttribute("Active", "true"); - } else { - node.setAttribute("Active", "false"); - } - if (task instanceof BugzillaTask) { - BugzillaTask bt = (BugzillaTask) task; - node.setAttribute("Bugzilla", "true"); - if (bt.getLastRefresh() != null) { - node.setAttribute("LastDate", new Long(bt.getLastRefreshTime() - .getTime()).toString()); - } else { - node.setAttribute("LastDate", new Long(new Date().getTime()).toString()); - } - - if (bt.isDirty()) { - node.setAttribute("Dirty", "true"); - } else { - node.setAttribute("Dirty", "false"); - } - bt.saveBugReport(false); - } else { - node.setAttribute("Bugzilla", "false"); - } - node.setAttribute("Notes", task.getNotes()); - node.setAttribute("Elapsed", task.getElapsedTime()); - node.setAttribute("Estimated", task.getEstimatedTime()); - List<String> rl = task.getRelatedLinks().getLinks(); - int i = 0; - for (String link : rl) { - node.setAttribute("link"+i, link); - i++; - } - - for (ITask t : task.getChildren()) { - writeTask(t, doc, node); - } - parent.appendChild(node); - return; - } - - public static void readTaskList(TaskList tlist, File inFile) { - try { - // parse file - // - Document doc = openAsDOM(inFile); - - // read root node to get version number - // - Element root = doc.getDocumentElement(); - readVersion = root.getAttribute("Version"); - - if (readVersion.equals("1.0.0")) { - NodeList list = root.getChildNodes(); - for (int i = 0; i < list.getLength(); i++) { - Node child = list.item(i); - readTasksToNewFormat(child, tlist); - //tlist.addRootTask(readTaskAndSubTasks(child, null, tlist)); - } - } else { - NodeList list = root.getChildNodes(); - for (int i = 0; i < list.getLength(); i++) { - Node child = list.item(i); - if (child.getNodeName().equals("Category") || - child.getNodeName().equals("TaskCategory")) { - readTaskCategory(child, tlist); - } else if (child.getNodeName().equals("BugzillaTaskRegistry")) { - readBugzillaRegistry(child, tlist); - } else if (child.getNodeName().equals("QueryCategory")) { - readQueryCategory(child, tlist); - } else { - tlist.addRootTask(readTask(child, tlist, null, null)); - } - } - } - } catch (Exception e) { - String name = inFile.getAbsolutePath(); - name = name.substring(0, name.lastIndexOf('.')) + "-save.xml"; - inFile.renameTo(new File(name)); - MylarPlugin.log(e, "XmlUtil"); - } - } - - private static void readBugzillaRegistry(Node node, TaskList tlist) { - NodeList list = node.getChildNodes(); - for (int i = 0; i < list.getLength(); i++) { - Node child = list.item(i); - ITask task = readTask(child, tlist, null, null); - if(task instanceof BugzillaTask){ - tlist.addToBugzillaTaskRegistry((BugzillaTask)task); - } - } - } - - /** - * Opens the specified XML file and parses it into a DOM Document. - * - * Filename - the name of the file to open - * Return - the Document built from the XML file - * Throws - XMLException if the file cannot be parsed as XML - * - IOException if the file cannot be opened - */ - private static Document openAsDOM(File inputFile) throws IOException { - - // A factory API that enables applications to obtain a parser - // that produces DOM object trees from XML documents - // - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - - // Using DocumentBuilder, obtain a Document from XML file. - // - DocumentBuilder builder = null; - Document document = null; - try { - // create new instance of DocumentBuilder - // - builder = factory.newDocumentBuilder(); - } catch (ParserConfigurationException pce) { - inputFile.renameTo(new File(inputFile.getName() + "save.xml")); - MylarPlugin.log(pce, "Failed to load XML file"); - } - try { - // Parse the content of the given file as an XML document - // and return a new DOM Document object. Also throws IOException - document = builder.parse(inputFile); - } catch (SAXException se) { - inputFile.renameTo(new File(inputFile.getName() + "save.xml")); - MylarPlugin.log(se, "Failed to parse XML file"); - } - return document; - } - -// private static ITask readTaskAndSubTasks(Node node, ITask root, TaskList tlist) { -// //extract node and create new sub task -// // -// Element e = (Element) node; -// ITask t; -// String handle = ""; -// if (e.hasAttribute("ID")) { -// handle = e.getAttribute("ID"); -// } else { -// handle = e.getAttribute("Handle"); -// } -// -// String label = e.getAttribute("Label"); -// String priority = e.getAttribute("Priority"); -// -// if (e.getAttribute("Bugzilla").compareTo("true") == 0) { -// t = new BugzillaTask(handle, label, true); -// BugzillaTask bt = (BugzillaTask) t; -// bt.setState(BugTaskState.FREE); -// bt.setLastRefresh(new Date(new Long(e.getAttribute("LastDate")) -// .longValue())); -// if (e.getAttribute("Dirty").compareTo("true") == 0) { -// bt.setDirty(true); -// } else { -// bt.setDirty(false); -// } -// if (bt.readBugReport() == false) { -// MylarPlugin.log("Failed to read bug report", null); -// } -// } else { -// t = new Task(handle, label); -// } -// t.setPriority(priority); -// t.setPath(e.getAttribute("Path")); -// -// if (e.getAttribute("Active").compareTo("true") == 0) { -// t.setActive(true); -// tlist.setActive(t, true); -// } else { -// t.setActive(false); -// } -// -// if (e.getAttribute("Complete").compareTo("true") == 0) { -// t.setCompleted(true); -// } else { -// t.setCompleted(false); -// } -// if (e.getAttribute("IsCategory").compareTo("true") == 0) { -// t.setIsCategory(true); -// } else { -// t.setIsCategory(false); -// } -// -// if (e.hasAttribute("Notes")) { -// t.setNotes(e.getAttribute("Notes")); -// } else { -// t.setNotes(""); -// } -// if (e.hasAttribute("Elapsed")) { -// t.setElapsedTime(e.getAttribute("Elapsed")); -// } else { -// t.setElapsedTime(""); -// } -// if (e.hasAttribute("Estimated")) { -// t.setEstimatedTime(e.getAttribute("Estimated")); -// } else { -// t.setEstimatedTime(""); -// } -// -// int i = 0; -// while (e.hasAttribute("link"+i)) { -// t.getRelatedLinks().add(e.getAttribute("link"+i)); -// i++; -// } -// -// if (!readVersion.equals("1.0.0")) { -// // for newer revisions -// } -// -// i = 0; -// NodeList list = e.getChildNodes(); -// for (i = 0; i < list.getLength(); i++) { -// Node child = list.item(i); -// t.addSubTask(readTaskAndSubTasks(child, t, tlist)); -// } -// if (root != null) { -// t.setParent(root); -// } -// return t; -// } - - private static void readTaskCategory(Node node, TaskList tlist) { - Element e = (Element) node; - TaskCategory cat = new TaskCategory(e.getAttribute("Name")); - tlist.addCategory(cat); - NodeList list = node.getChildNodes(); - for (int i = 0; i < list.getLength(); i++) { - Node child = list.item(i); - cat.addTask(readTask(child, tlist, cat, null)); - } - } - - private static void readQueryCategory(Node node, TaskList tlist) { - Element e = (Element) node; - BugzillaQueryCategory cat = new BugzillaQueryCategory(e.getAttribute("Description"), e.getAttribute("URL")); - tlist.addCategory(cat); - } - - private static ITask readTask(Node node, TaskList tlist, TaskCategory cat, ITask parent) { - Element e = (Element) node; - ITask t; - String handle = e.getAttribute("Handle"); - String label = e.getAttribute("Label"); - String priority = e.getAttribute("Priority"); - - if (e.getAttribute("Bugzilla").compareTo("true") == 0) { - t = new BugzillaTask(handle, label, true); - BugzillaTask bt = (BugzillaTask) t; - bt.setState(BugTaskState.FREE); - bt.setLastRefresh(new Date(new Long(e.getAttribute("LastDate")) - .longValue())); - if (e.getAttribute("Dirty").compareTo("true") == 0) { - bt.setDirty(true); - } else { - bt.setDirty(false); - } - if (bt.readBugReport() == false) { - MylarPlugin.log("Failed to read bug report", null); - } - } else { - t = new Task(handle, label); - } - t.setPriority(priority); - t.setPath(e.getAttribute("Path")); - - if (e.getAttribute("Active").compareTo("true") == 0) { - t.setActive(true); - tlist.setActive(t, true); - } else { - t.setActive(false); - } - if (e.getAttribute("Complete").compareTo("true") == 0) { - t.setCompleted(true); - } else { - t.setCompleted(false); - } - if (e.hasAttribute("Notes")) { - t.setNotes(e.getAttribute("Notes")); - } else { - t.setNotes(""); - } - if (e.hasAttribute("Elapsed")) { - t.setElapsedTime(e.getAttribute("Elapsed")); - } else { - t.setElapsedTime(""); - } - if (e.hasAttribute("Estimated")) { - t.setEstimatedTime(e.getAttribute("Estimated")); - } else { - t.setEstimatedTime(""); - } - - int i = 0; - while (e.hasAttribute("link"+i)) { - t.getRelatedLinks().add(e.getAttribute("link"+i)); - i++; - } - t.setCategory(cat); - t.setParent(parent); - NodeList list = e.getChildNodes(); - for (i = 0; i < list.getLength(); i++) { - Node child = list.item(i); - t.addSubTask(readTask(child, tlist, null, t)); - } - return t; - } - - private static void readTasksToNewFormat(Node node, TaskList tlist) { - Element e = (Element) node; - ITask t; - String handle = e.getAttribute("Handle"); - String label = e.getAttribute("Label"); - - if (e.getAttribute("IsCategory").compareTo("true") == 0) { - TaskCategory c = new TaskCategory(label); - NodeList list = e.getChildNodes(); - for (int i = 0; i < list.getLength(); i++) { - Node child = list.item(i); - readSubTasksToNewFormat(child, tlist, c); - } - tlist.addCategory(c); - } else { - String priority = e.getAttribute("Priority"); - if (e.getAttribute("Bugzilla").compareTo("true") == 0) { - t = new BugzillaTask(handle, label, true); - BugzillaTask bt = (BugzillaTask) t; - bt.setState(BugTaskState.FREE); - bt.setLastRefresh(new Date(new Long(e.getAttribute("LastDate")) - .longValue())); - if (e.getAttribute("Dirty").compareTo("true") == 0) { - bt.setDirty(true); - } else { - bt.setDirty(false); - } - if (bt.readBugReport() == false) { - MylarPlugin.log("Failed to read bug report", null); - } - } else { - t = new Task(handle, label); - } - t.setPriority(priority); - t.setPath(e.getAttribute("Path")); - t.setNotes(e.getAttribute("Notes")); - t.setElapsedTime(e.getAttribute("Elapsed")); - t.setEstimatedTime(e.getAttribute("Estimated")); - - if (e.getAttribute("Active").compareTo("true") == 0) { - t.setActive(true); - tlist.setActive(t, true); - } else { - t.setActive(false); - } - if (e.getAttribute("Complete").compareTo("true") == 0) { - t.setCompleted(true); - } else { - t.setCompleted(false); - } - - int i = 0; - while (e.hasAttribute("link" + i)) { - t.getRelatedLinks().add(e.getAttribute("link" + i)); - i++; - } - tlist.addRootTask(t); - i = 0; - NodeList list = e.getChildNodes(); - for (i = 0; i < list.getLength(); i++) { - Node child = list.item(i); - readSubTasksToNewFormat(child, tlist, null); - } - } - } - private static void readSubTasksToNewFormat(Node node, TaskList tlist, TaskCategory cat) { - Element e = (Element) node; - ITask t; - String handle = e.getAttribute("Handle"); - String label = e.getAttribute("Label"); - String priority = e.getAttribute("Priority"); - if (e.getAttribute("Bugzilla").compareTo("true") == 0) { - t = new BugzillaTask(handle, label, true); - BugzillaTask bt = (BugzillaTask) t; - bt.setState(BugTaskState.FREE); - bt.setLastRefresh(new Date(new Long(e.getAttribute("LastDate")) - .longValue())); - if (e.getAttribute("Dirty").compareTo("true") == 0) { - bt.setDirty(true); - } else { - bt.setDirty(false); - } - if (bt.readBugReport() == false) { - MylarPlugin.log("Failed to read bug report", null); - } - } else { - t = new Task(handle, label); - } - t.setPriority(priority); - t.setPath(e.getAttribute("Path")); - t.setNotes(e.getAttribute("Notes")); - t.setElapsedTime(e.getAttribute("Elapsed")); - t.setEstimatedTime(e.getAttribute("Estimated")); - - if (e.getAttribute("Active").compareTo("true") == 0) { - t.setActive(true); - tlist.setActive(t, true); - } else { - t.setActive(false); - } - if (e.getAttribute("Complete").compareTo("true") == 0) { - t.setCompleted(true); - } else { - t.setCompleted(false); - } - - int i = 0; - while (e.hasAttribute("link" + i)) { - t.getRelatedLinks().add(e.getAttribute("link" + i)); - i++; - } - if (cat == null) { - tlist.addRootTask(t); - } else { - cat.addTask(t); - t.setCategory(cat); - } - - i = 0; - NodeList list = e.getChildNodes(); - for (i = 0; i < list.getLength(); i++) { - Node child = list.item(i); - readSubTasksToNewFormat(child, tlist, cat); - } - } -} - |