Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkersten2007-06-25 03:00:25 +0000
committermkersten2007-06-25 03:00:25 +0000
commit1862c8dfea7bdf0dc525c7eca6a581bee0383bd7 (patch)
treeb3a021b25341aec0b9cfb08a25ab3035da101ced
parent49d2f47f7f707a8d71bbd28dbf877f3e1ad7abbd (diff)
downloadorg.eclipse.mylyn.tasks-1862c8dfea7bdf0dc525c7eca6a581bee0383bd7.tar.gz
org.eclipse.mylyn.tasks-1862c8dfea7bdf0dc525c7eca6a581bee0383bd7.tar.xz
org.eclipse.mylyn.tasks-1862c8dfea7bdf0dc525c7eca6a581bee0383bd7.zip
RESOLVED - bug 172699: [new uex] create new task list query from search results
https://bugs.eclipse.org/bugs/show_bug.cgi?id=172699
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/AddExistingTaskJob.java14
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorActionContributor.java1
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/search/CreateQueryFromSearchAction.java81
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/search/RepositorySearchResultView.java83
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListDropAdapter.java8
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractRepositoryTaskEditor.java6
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/search/SearchHitCollector.java6
7 files changed, 165 insertions, 34 deletions
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/AddExistingTaskJob.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/AddExistingTaskJob.java
index 973c08166..796cd3a88 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/AddExistingTaskJob.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/AddExistingTaskJob.java
@@ -1,6 +1,7 @@
package org.eclipse.mylyn.internal.tasks.ui;
import java.text.MessageFormat;
+import java.util.Calendar;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -63,15 +64,11 @@ public class AddExistingTaskJob extends Job {
repository.getConnectorKind());
try {
final AbstractTask newTask = connector.createTaskFromExistingId(repository, taskId, monitor);
-
-// if (newTask instanceof AbstractTask) {
-// // TODO: encapsulate in abstract connector
-// AbstractTask repositoryTask = (AbstractTask) newTask;
-// TasksUiPlugin.getTaskDataManager().push(newTask.getHandleIdentifier(),
-// repositoryTask.getTaskData());
-// }
-
if (newTask != null) {
+ Calendar newSchedule = Calendar.getInstance();
+ TasksUiPlugin.getTaskListManager().setScheduledEndOfDay(newSchedule);
+ TasksUiPlugin.getTaskListManager().setScheduledFor(newTask, newSchedule.getTime());
+
TasksUiUtil.refreshAndOpenTaskListElement(newTask);
PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
@@ -90,7 +87,6 @@ public class AddExistingTaskJob extends Job {
TasksUiPlugin.getTaskListManager().getTaskList().moveToContainer(newTask, category);
taskListView.getViewer().setSelection(new StructuredSelection(newTask));
}
-
});
} else {
PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorActionContributor.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorActionContributor.java
index bedc29b06..44a604023 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorActionContributor.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorActionContributor.java
@@ -175,7 +175,6 @@ public class TaskEditorActionContributor extends MultiPageEditorActionBarContrib
List<AbstractTaskCategory> categories = new ArrayList<AbstractTaskCategory>(
TasksUiPlugin.getTaskListManager().getTaskList().getCategories());
- // This is added to solve Bug 180252
Collections.sort(categories);
for (final AbstractTaskCategory category : categories) {
if (!category.equals(TasksUiPlugin.getTaskListManager().getTaskList().getArchiveContainer())) {
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/search/CreateQueryFromSearchAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/search/CreateQueryFromSearchAction.java
new file mode 100644
index 000000000..ac76f9a06
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/search/CreateQueryFromSearchAction.java
@@ -0,0 +1,81 @@
+/*******************************************************************************
+ * Copyright (c) 2004 - 20067 Mylyn committers 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
+ *******************************************************************************/
+
+package org.eclipse.mylyn.internal.tasks.ui.search;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.mylyn.internal.tasks.ui.TasksUiImages;
+import org.eclipse.mylyn.internal.tasks.ui.views.TaskListView;
+import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
+import org.eclipse.mylyn.tasks.core.AbstractRepositoryQuery;
+import org.eclipse.mylyn.tasks.core.AbstractTask;
+import org.eclipse.mylyn.tasks.ui.TasksUiPlugin;
+import org.eclipse.mylyn.tasks.ui.search.SearchHitCollector;
+import org.eclipse.search.ui.ISearchQuery;
+import org.eclipse.search.ui.NewSearchUI;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * Used for add the last search result to the Task List.
+ *
+ * @author Balazs Brinkus (bug 172699)
+ * @author Mik Kersten
+ */
+public class CreateQueryFromSearchAction extends Action {
+
+ /** The view this action works on */
+ private RepositorySearchResultView resultView;
+
+ /**
+ * Constructor
+ *
+ * @param text
+ * The text for this action
+ * @param resultView
+ * The <code>RepositorySearchResultView</code> this action works on
+ */
+ public CreateQueryFromSearchAction(String text, RepositorySearchResultView resultView) {
+ setText(text);
+ setImageDescriptor(TasksUiImages.QUERY_NEW);
+ this.resultView = resultView;
+ }
+
+ /**
+ * Add the search result to the Task List.
+ */
+ public void run() {
+ ISelection selection = resultView.getViewer().getSelection();
+ if (selection instanceof IStructuredSelection) {
+ IStructuredSelection structuredSelection = (IStructuredSelection) selection;
+ if (structuredSelection.getFirstElement() instanceof AbstractTask) {
+ ISearchQuery[] queries = NewSearchUI.getQueries();
+ AbstractTask task = (AbstractTask) structuredSelection.getFirstElement();
+ AbstractRepositoryConnector connector = TasksUiPlugin.getRepositoryManager().getRepositoryConnector(
+ task.getConnectorKind());
+ if (queries.length != 0 && connector != null) {
+ SearchHitCollector searchHitCollector = (SearchHitCollector) queries[0];
+ AbstractRepositoryQuery query = (AbstractRepositoryQuery) searchHitCollector.getRepositoryQuery();
+ InputDialog dialog = new InputDialog(PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow()
+ .getShell(), "Create Query", "Name of query to be added to the " + TaskListView.LABEL_VIEW + ": ", "", null);
+ int dialogResult = dialog.open();
+ if (dialogResult == Window.OK) {
+ query.setHandleIdentifier(dialog.getValue());
+ TasksUiPlugin.getTaskListManager().getTaskList().addQuery(query);
+ TasksUiPlugin.getSynchronizationManager().synchronize(connector, query, null, true);
+ }
+ }
+ }
+ }
+ }
+
+}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/search/RepositorySearchResultView.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/search/RepositorySearchResultView.java
index fc5e3a3e0..db556423c 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/search/RepositorySearchResultView.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/search/RepositorySearchResultView.java
@@ -10,20 +10,35 @@
*******************************************************************************/
package org.eclipse.mylyn.internal.tasks.ui.search;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.viewers.ILabelDecorator;
import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.mylyn.internal.tasks.ui.AddExistingTaskJob;
+import org.eclipse.mylyn.internal.tasks.ui.IDynamicSubMenuContributor;
import org.eclipse.mylyn.internal.tasks.ui.TaskListColorsAndFonts;
+import org.eclipse.mylyn.internal.tasks.ui.TasksUiImages;
import org.eclipse.mylyn.internal.tasks.ui.views.TaskElementLabelProvider;
+import org.eclipse.mylyn.internal.tasks.ui.views.TaskListView;
import org.eclipse.mylyn.internal.tasks.ui.views.TaskTableLabelProvider;
import org.eclipse.mylyn.tasks.core.AbstractTask;
+import org.eclipse.mylyn.tasks.core.AbstractTaskCategory;
+import org.eclipse.mylyn.tasks.core.AbstractTaskContainer;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.tasks.ui.TasksUiUtil;
+import org.eclipse.mylyn.tasks.ui.editors.RepositoryTaskEditorInput;
import org.eclipse.search.internal.ui.SearchMessages;
import org.eclipse.search.ui.IContextMenuConstants;
import org.eclipse.search.ui.text.AbstractTextSearchViewPage;
@@ -33,10 +48,12 @@ import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IPageLayout;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.IShowInTargetList;
+import org.eclipse.ui.progress.IProgressService;
import org.eclipse.ui.themes.IThemeManager;
/**
@@ -75,6 +92,8 @@ public class RepositorySearchResultView extends AbstractTextSearchViewPage imple
private OpenSearchResultAction openInEditorAction;
+ private CreateQueryFromSearchAction addTaskListAction;
+
private static final String[] SHOW_IN_TARGETS = new String[] { IPageLayout.ID_RES_NAV };
private static final IShowInTargetList SHOW_IN_TARGET_LIST = new IShowInTargetList() {
@@ -95,6 +114,7 @@ public class RepositorySearchResultView extends AbstractTextSearchViewPage imple
currentSortOrder = ORDER_DEFAULT;
openInEditorAction = new OpenSearchResultAction("Open in Editor", this);
+ addTaskListAction = new CreateQueryFromSearchAction("Create Query from Search...", this);
}
@Override
@@ -212,25 +232,66 @@ public class RepositorySearchResultView extends AbstractTextSearchViewPage imple
throws PartInitException {
AbstractTask repositoryHit = (AbstractTask) match.getElement();
- TasksUiUtil.openRepositoryTask(repositoryHit.getRepositoryUrl(), repositoryHit.getTaskId(), repositoryHit
- .getUrl());
+ TasksUiUtil.openRepositoryTask(repositoryHit.getRepositoryUrl(), repositoryHit.getTaskId(),
+ repositoryHit.getUrl());
}
@Override
- protected void fillContextMenu(IMenuManager mgr) {
- super.fillContextMenu(mgr);
-
- // Create the submenu for sorting
- MenuManager sortMenu = new MenuManager(SearchMessages.SortDropDownAction_label);
- sortMenu.add(sortByPriorityAction);
- sortMenu.add(sortByDescriptionAction);
+ protected void fillContextMenu(IMenuManager menuManager) {
+ super.fillContextMenu(menuManager);
+ MenuManager sortMenuManager = new MenuManager(SearchMessages.SortDropDownAction_label);
+ sortMenuManager.add(sortByPriorityAction);
+ sortMenuManager.add(sortByDescriptionAction);
sortByPriorityAction.setChecked(currentSortOrder == sortByPriorityAction.getSortOrder());
sortByDescriptionAction.setChecked(currentSortOrder == sortByDescriptionAction.getSortOrder());
// Add the new context menu items
- mgr.appendToGroup(IContextMenuConstants.GROUP_VIEWER_SETUP, sortMenu);
- mgr.appendToGroup(IContextMenuConstants.GROUP_OPEN, openInEditorAction);
+ menuManager.appendToGroup(IContextMenuConstants.GROUP_VIEWER_SETUP, sortMenuManager);
+ menuManager.appendToGroup(IContextMenuConstants.GROUP_OPEN, openInEditorAction);
+ menuManager.appendToGroup(IContextMenuConstants.GROUP_OPEN, addTaskListAction);
+
+ // HACK: this should be a contribution
+ final MenuManager subMenuManager = new MenuManager("Add to " + TaskListView.LABEL_VIEW + " Category");
+ List<AbstractTaskCategory> categories = new ArrayList<AbstractTaskCategory>(TasksUiPlugin.getTaskListManager()
+ .getTaskList()
+ .getCategories());
+
+ Collections.sort(categories);
+ for (final AbstractTaskCategory category : categories) {
+ if (!category.equals(TasksUiPlugin.getTaskListManager().getTaskList().getArchiveContainer())) {
+ Action action = new Action() {
+ @Override
+ public void run() {
+ moveToCategory(category);
+ }
+ };
+ String text = category.getSummary();
+ action.setText(text);
+ action.setImageDescriptor(TasksUiImages.CATEGORY);
+ subMenuManager.add(action);
+ }
+ }
+ menuManager.appendToGroup(IContextMenuConstants.GROUP_OPEN, subMenuManager);
+ }
+
+ private void moveToCategory(AbstractTaskCategory category) {
+ final IProgressService progressService = PlatformUI.getWorkbench().getProgressService();
+ StructuredSelection selection = (StructuredSelection) this.getViewer().getSelection();
+ for (Iterator<?> iterator = selection.iterator(); iterator.hasNext();) {
+ Object selectedObject = iterator.next();
+ if (selectedObject instanceof AbstractTask) {
+ AbstractTask task = (AbstractTask) selectedObject;
+ TaskRepository repository = TasksUiPlugin.getRepositoryManager().getRepository(task.getRepositoryUrl());
+ final AddExistingTaskJob job = new AddExistingTaskJob(repository, task.getTaskId(), category);
+ job.schedule();
+ PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ progressService.showInDialog(RepositorySearchResultView.this.getSite().getShell(), job);
+ }
+ });
+ }
+ }
}
class SearchViewTableLabelProvider extends TaskTableLabelProvider {
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListDropAdapter.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListDropAdapter.java
index baff013a9..e440ec85b 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListDropAdapter.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/views/TaskListDropAdapter.java
@@ -197,14 +197,6 @@ public class TaskListDropAdapter extends ViewerDropAdapter {
if (repository.getUrl().equals(repositoryUrl)) {
try {
newTask = connector.createTaskFromExistingId(repository, id, new NullProgressMonitor());
-
-// if (newTask instanceof AbstractTask) {
-// // TODO: encapsulate in abstract connector
-// AbstractTask repositoryTask = (AbstractTask) newTask;
-// TasksUiPlugin.getTaskDataManager().push(
-// RepositoryTaskHandleUtil.getHandle(repository.getUrl(), id),
-// repositoryTask.getTaskData());
-// }
TasksUiUtil.refreshAndOpenTaskListElement(newTask);
return true;
} catch (CoreException e) {
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractRepositoryTaskEditor.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractRepositoryTaskEditor.java
index c36d04dfc..2ce5af199 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractRepositoryTaskEditor.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/editors/AbstractRepositoryTaskEditor.java
@@ -2723,7 +2723,8 @@ public abstract class AbstractRepositoryTaskEditor extends TaskFormPage {
if (modifiedTask != null) {
// Attach context if required
if (attachContext && connector.getAttachmentHandler() != null) {
- connector.getAttachmentHandler().attachContext(repository, modifiedTask, "", new SubProgressMonitor(monitor, 1));
+ connector.getAttachmentHandler().attachContext(repository, modifiedTask, "",
+ new SubProgressMonitor(monitor, 1));
}
modifiedTask.setSubmitting(true);
@@ -2927,15 +2928,12 @@ public abstract class AbstractRepositoryTaskEditor extends TaskFormPage {
public void run() {
if (getCategory() != null) {
TasksUiPlugin.getTaskListManager().getTaskList().moveToContainer(newTask, getCategory());
-
}
}
});
-
}
return newTask;
-
}
/**
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/search/SearchHitCollector.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/search/SearchHitCollector.java
index d68969373..ba742e94f 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/search/SearchHitCollector.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/search/SearchHitCollector.java
@@ -223,4 +223,8 @@ public class SearchHitCollector implements ISearchQuery, ITaskCollector {
return taskResults;
}
-} \ No newline at end of file
+ public AbstractRepositoryQuery getRepositoryQuery() {
+ return repositoryQuery;
+ }
+
+}

Back to the top