blob: ded2e3b5fbfa83248c2883370e06bab62ec38c00 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
/*******************************************************************************
* Copyright (c) 2004, 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:
* Ken Sueda - initial API and implementation
* Tasktop Technologies - improvements
*******************************************************************************/
package org.eclipse.mylyn.internal.tasks.ui.actions;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.mylyn.commons.ui.CommonImages;
import org.eclipse.mylyn.internal.tasks.core.AbstractTask;
import org.eclipse.mylyn.internal.tasks.core.AbstractTaskCategory;
import org.eclipse.mylyn.internal.tasks.core.TaskCategory;
import org.eclipse.mylyn.internal.tasks.ui.util.TasksUiInternal;
import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.ui.actions.BaseSelectionListenerAction;
/**
* @author Ken Sueda
* @author Mik Kersten
*/
public class RemoveFromCategoryAction extends BaseSelectionListenerAction {
public static final String ID = "org.eclipse.mylyn.tasklist.actions.remove"; //$NON-NLS-1$
public RemoveFromCategoryAction() {
super(Messages.RemoveFromCategoryAction_Remove_From_Category);
setId(ID);
setImageDescriptor(CommonImages.REMOVE);
}
@Override
public void run() {
IStructuredSelection selection = getStructuredSelection();
for (Object selectedObject : selection.toList()) {
if (selectedObject instanceof ITask) {
AbstractTask task = (AbstractTask) selectedObject;
AbstractTaskCategory category = TaskCategory.getParentTaskCategory(task);
if (category != null) {
TasksUiInternal.getTaskList().removeFromContainer(category, task);
}
}
}
}
}
|