Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2011-02-09 06:31:26 +0000
committerspingel2011-02-09 06:31:26 +0000
commit81054e3f0df2c6d210450e2613b740aad87a935e (patch)
tree35045ff81bed411dbee4ba17a992873f4487140e /org.eclipse.mylyn.tasks.ui
parent40a124182f4d13d7cfa672e28a810bb270f2c5f8 (diff)
downloadorg.eclipse.mylyn.tasks-81054e3f0df2c6d210450e2613b740aad87a935e.tar.gz
org.eclipse.mylyn.tasks-81054e3f0df2c6d210450e2613b740aad87a935e.tar.xz
org.eclipse.mylyn.tasks-81054e3f0df2c6d210450e2613b740aad87a935e.zip
NEW - bug 325005: support deleting task repository from the team repositories view
https://bugs.eclipse.org/bugs/show_bug.cgi?id=325005
Diffstat (limited to 'org.eclipse.mylyn.tasks.ui')
-rw-r--r--org.eclipse.mylyn.tasks.ui/plugin.xml28
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/DeleteTaskRepositoryAction.java19
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/commands/DeleteTaskRepositoryHandler.java39
3 files changed, 80 insertions, 6 deletions
diff --git a/org.eclipse.mylyn.tasks.ui/plugin.xml b/org.eclipse.mylyn.tasks.ui/plugin.xml
index 19e5c7e90..99db16c58 100644
--- a/org.eclipse.mylyn.tasks.ui/plugin.xml
+++ b/org.eclipse.mylyn.tasks.ui/plugin.xml
@@ -2014,6 +2014,34 @@
id="org.eclipse.mylyn.tasks.ui.wizard.NewTaskRepository">
</primaryWizard>
</extension>
+ <extension
+ point="org.eclipse.ui.handlers">
+ <handler
+ class="org.eclipse.mylyn.internal.tasks.ui.commands.DeleteTaskRepositoryHandler"
+ commandId="org.eclipse.ui.edit.delete">
+ <activeWhen>
+ <and>
+ <with
+ variable="activePartId">
+ <equals
+ value="org.eclipse.mylyn.commons.team.navigator.Repositories">
+ </equals>
+ </with>
+ <count
+ value="1">
+ </count>
+ <iterate>
+ <and>
+ <instanceof
+ value="org.eclipse.mylyn.tasks.core.TaskRepository">
+ </instanceof>
+ </and>
+ </iterate>
+ </and>
+ </activeWhen>
+ </handler>
+ </extension>
+
<!--
<extension
point="org.eclipse.mylyn.commons.notifications.notifications">
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/DeleteTaskRepositoryAction.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/DeleteTaskRepositoryAction.java
index 1ab60ef0b..9fb7aa0a5 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/DeleteTaskRepositoryAction.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/actions/DeleteTaskRepositoryAction.java
@@ -16,6 +16,7 @@ import java.util.Collection;
import java.util.List;
import java.util.Set;
+import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
@@ -66,9 +67,14 @@ public class DeleteTaskRepositoryAction extends AbstractTaskRepositoryAction {
@Override
public void run() {
final TaskRepository repositoryToDelete = getTaskRepository(getStructuredSelection());
- if (repositoryToDelete == null) {
- return;
+ if (repositoryToDelete != null) {
+ run(repositoryToDelete);
}
+ }
+
+ public static void run(final TaskRepository repositoryToDelete) {
+ Assert.isNotNull(repositoryToDelete);
+
final List<IRepositoryQuery> queriesToDelete = new ArrayList<IRepositoryQuery>();
final List<AbstractTask> tasksToDelete = new ArrayList<AbstractTask>();
@@ -105,10 +111,11 @@ public class DeleteTaskRepositoryAction extends AbstractTaskRepositoryAction {
// confirm that the user wants to delete all tasks and queries that are associated
boolean deleteConfirmed;
if (queriesToDelete.size() > 0 || tasksToDelete.size() > 0) {
- deleteConfirmed = MessageDialog.openQuestion(WorkbenchUtil.getShell(),
- Messages.DeleteTaskRepositoryAction_Confirm_Delete, NLS.bind(
- Messages.DeleteTaskRepositoryAction_Delete_the_selected_task_repositories, new Integer[] {
- tasksToDelete.size(), queriesToDelete.size() }));
+ deleteConfirmed = MessageDialog.openQuestion(
+ WorkbenchUtil.getShell(),
+ Messages.DeleteTaskRepositoryAction_Confirm_Delete,
+ NLS.bind(Messages.DeleteTaskRepositoryAction_Delete_the_selected_task_repositories, new Integer[] {
+ tasksToDelete.size(), queriesToDelete.size() }));
} else {
deleteConfirmed = MessageDialog.openQuestion(WorkbenchUtil.getShell(),
Messages.DeleteTaskRepositoryAction_Confirm_Delete, NLS.bind(
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/commands/DeleteTaskRepositoryHandler.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/commands/DeleteTaskRepositoryHandler.java
new file mode 100644
index 000000000..a82bb4138
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/commands/DeleteTaskRepositoryHandler.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2011 Tasktop Technologies 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:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.internal.tasks.ui.commands;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.mylyn.internal.tasks.ui.actions.DeleteTaskRepositoryAction;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/**
+ * @author Steffen Pingel
+ */
+public class DeleteTaskRepositoryHandler extends AbstractHandler {
+
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ ISelection selection = HandlerUtil.getCurrentSelection(event);
+ if (selection instanceof IStructuredSelection) {
+ Object item = ((IStructuredSelection) selection).getFirstElement();
+ if (item instanceof TaskRepository) {
+ DeleteTaskRepositoryAction.run((TaskRepository) item);
+ }
+ }
+ return null;
+ }
+
+}

Back to the top