Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 169426 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/mylyn/internal/tasks/ui/actions/NewTaskFromCommentAction.java (+4 lines)
Lines 46-51 Link Here
46
	@Override
46
	@Override
47
	public void run() {
47
	public void run() {
48
		AbstractRepositoryConnector connector = null;
48
		AbstractRepositoryConnector connector = null;
49
50
		if (taskData == null)
51
			return;
52
49
		TaskRepositoryManager repositoryManager = TasksUiPlugin.getRepositoryManager();
53
		TaskRepositoryManager repositoryManager = TasksUiPlugin.getRepositoryManager();
50
		connector = repositoryManager.getRepositoryConnector(taskData.getRepositoryKind());
54
		connector = repositoryManager.getRepositoryConnector(taskData.getRepositoryKind());
51
		String textToInsert ;
55
		String textToInsert ;
(-)src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorActionContributor.java (-24 / +32 lines)
Lines 224-253 Link Here
224
			manager.add(synchronizeEditorAction);
224
			manager.add(synchronizeEditorAction);
225
			manager.add(openWithBrowserAction);
225
			manager.add(openWithBrowserAction);
226
226
227
			if (this.getEditor().getActivePageInstance() instanceof AbstractRepositoryTaskEditor) {
228
				if (this.getEditor().getSelection() instanceof RepositoryTaskSelection) {
229
					RepositoryTaskSelection repositoryTaskSelection = (RepositoryTaskSelection) this.getEditor()
230
							.getSelection();
231
					TaskComment comment = repositoryTaskSelection.getComment();
232
					if (comment != null) {
233
						newTaskFromCommentAction.setTaskComment(comment);
234
						AbstractRepositoryTaskEditor editor = (AbstractRepositoryTaskEditor) this.getEditor()
235
								.getActivePageInstance();
236
						if (getEditor().getActivePageInstance() instanceof TaskFormPage) {
237
							TaskFormPage formPage = (TaskFormPage) getEditor().getActivePageInstance();
238
							String selectionText = formPage.getSelectionText();
239
							newTaskFromCommentAction.setSelectedCommentText(selectionText);
240
						}
241
						IEditorInput input = editor.getEditorInput();
242
						if (input instanceof RepositoryTaskEditorInput) {
243
							RepositoryTaskEditorInput repositoryInput = (RepositoryTaskEditorInput) input;
244
							newTaskFromCommentAction.setTaskData(repositoryInput.getTaskData());
245
						}
246
						manager.add(newTaskFromCommentAction);
247
					}
248
				}
249
			}
250
251
			if (task.isActive()) {
227
			if (task.isActive()) {
252
				manager.add(new TaskDeactivateAction() {
228
				manager.add(new TaskDeactivateAction() {
253
					@Override
229
					@Override
Lines 309-314 Link Here
309
					});
285
					});
310
		}
286
		}
311
287
288
		if (this.getEditor().getActivePageInstance() instanceof AbstractRepositoryTaskEditor) {
289
			if (this.getEditor().getSelection() instanceof RepositoryTaskSelection) {
290
				RepositoryTaskSelection repositoryTaskSelection = (RepositoryTaskSelection) this.getEditor()
291
						.getSelection();
292
				TaskComment comment = repositoryTaskSelection.getComment();
293
				if (comment != null) {
294
					newTaskFromCommentAction.setTaskComment(comment);
295
					AbstractRepositoryTaskEditor editor = (AbstractRepositoryTaskEditor) this.getEditor()
296
							.getActivePageInstance();
297
					if (getEditor().getActivePageInstance() instanceof TaskFormPage) {
298
						TaskFormPage formPage = (TaskFormPage) getEditor().getActivePageInstance();
299
						String selectionText = formPage.getSelectionText();
300
						newTaskFromCommentAction.setSelectedCommentText(selectionText);
301
					}
302
					IEditorInput input = editor.getEditorInput();
303
					if (input instanceof RepositoryTaskEditorInput) {
304
						RepositoryTaskEditorInput repositoryInput = (RepositoryTaskEditorInput) input;
305
						if (repositoryInput.getTaskData() != null) {
306
							newTaskFromCommentAction.setTaskData(repositoryInput.getTaskData());
307
							IMenuManager subMenu = manager.findMenuUsingPath("org.eclipse.mylyn.tasks.ui.menu.new");
308
							if (subMenu == null) {
309
								subMenu = new MenuManager("New", "org.eclipse.mylyn.tasks.ui.menu.new");
310
								manager.add(new Separator());
311
								manager.add(subMenu);
312
							}
313
							subMenu.add(newTaskFromCommentAction);
314
						}
315
					}
316
				}
317
			}
318
		}
319
312
		manager.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
320
		manager.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
313
	}
321
	}
314
322
(-)src/org/eclipse/mylyn/tasks/tests/AllTasksTests.java (+1 lines)
Lines 26-31 Link Here
26
		suite.addTestSuite(TaskRepositorySorterTest.class);
26
		suite.addTestSuite(TaskRepositorySorterTest.class);
27
		suite.addTestSuite(TaskDataManagerTest.class);
27
		suite.addTestSuite(TaskDataManagerTest.class);
28
		suite.addTestSuite(CopyDetailsActionTest.class);
28
		suite.addTestSuite(CopyDetailsActionTest.class);
29
		suite.addTestSuite(NewTaskFromCommentActionTest.class);
29
		suite.addTestSuite(TaskListTest.class);
30
		suite.addTestSuite(TaskListTest.class);
30
		suite.addTestSuite(ProjectRepositoryAssociationTest.class);
31
		suite.addTestSuite(ProjectRepositoryAssociationTest.class);
31
		suite.addTestSuite(TaskList06DataMigrationTest.class);
32
		suite.addTestSuite(TaskList06DataMigrationTest.class);
(-)src/org/eclipse/mylyn/tasks/tests/NewTaskFromCommentActionTest.java (+78 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2007 Mylyn project committers and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *******************************************************************************/
8
9
package org.eclipse.mylyn.tasks.tests;
10
11
import java.util.Date;
12
import java.util.HashMap;
13
import java.util.Map;
14
15
import junit.framework.TestCase;
16
17
import org.eclipse.mylyn.internal.tasks.ui.actions.NewTaskFromCommentAction;
18
import org.eclipse.mylyn.tasks.core.AbstractAttributeFactory;
19
import org.eclipse.mylyn.tasks.core.RepositoryTaskData;
20
import org.eclipse.mylyn.tasks.core.TaskComment;
21
22
public class NewTaskFromCommentActionTest extends TestCase {
23
24
	public void testNewTaskFromCommentAction() throws Exception {
25
		StubAttributeFactory targetFactory = new StubAttributeFactory();
26
		RepositoryTaskData repositoryTaskData = new RepositoryTaskData(targetFactory, "otherkind", "http://url", "2");
27
		TaskComment taskComment = new TaskComment(targetFactory, 1);
28
29
		NewTaskFromCommentAction newTaskFromCommentAction = new NewTaskFromCommentAction();
30
		newTaskFromCommentAction.setTaskData(repositoryTaskData);
31
		newTaskFromCommentAction.setTaskData(null);
32
		newTaskFromCommentAction.setTaskComment(taskComment);
33
		try {
34
			newTaskFromCommentAction.run();
35
		} catch (NullPointerException e) {
36
			fail("NullPointerException not expected");
37
		}
38
39
	}
40
41
	private class StubAttributeFactory extends AbstractAttributeFactory {
42
43
		private static final long serialVersionUID = 1L;
44
45
		private Map<String, String> attributeMap = new HashMap<String, String>();
46
47
		@Override
48
		public Date getDateForAttributeType(String attributeKey, String dateString) {
49
			// ignore
50
			return null;
51
		}
52
53
		@Override
54
		public String getName(String key) {
55
			// ignore
56
			return null;
57
		}
58
59
		@Override
60
		public boolean isHidden(String key) {
61
			// ignore
62
			return false;
63
		}
64
65
		@Override
66
		public boolean isReadOnly(String key) {
67
			// ignore
68
			return false;
69
		}
70
71
		@Override
72
		public String mapCommonAttributeKey(String key) {
73
			String mappedKey = attributeMap.get(key);
74
			return (mappedKey != null) ? mappedKey : key;
75
		}
76
77
	}
78
}

Return to bug 169426