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/editors/TaskEditorActionContributor.java (-1 / +24 lines)
Lines 32-37 Link Here
32
import org.eclipse.mylyn.internal.tasks.ui.actions.AbstractTaskEditorAction;
32
import org.eclipse.mylyn.internal.tasks.ui.actions.AbstractTaskEditorAction;
33
import org.eclipse.mylyn.internal.tasks.ui.actions.AttachFileAction;
33
import org.eclipse.mylyn.internal.tasks.ui.actions.AttachFileAction;
34
import org.eclipse.mylyn.internal.tasks.ui.actions.CopyTaskDetailsAction;
34
import org.eclipse.mylyn.internal.tasks.ui.actions.CopyTaskDetailsAction;
35
import org.eclipse.mylyn.internal.tasks.ui.actions.NewBugFromCommentAction;
35
import org.eclipse.mylyn.internal.tasks.ui.actions.OpenWithBrowserAction;
36
import org.eclipse.mylyn.internal.tasks.ui.actions.OpenWithBrowserAction;
36
import org.eclipse.mylyn.internal.tasks.ui.actions.ShowInTaskListAction;
37
import org.eclipse.mylyn.internal.tasks.ui.actions.ShowInTaskListAction;
37
import org.eclipse.mylyn.internal.tasks.ui.actions.SynchronizeEditorAction;
38
import org.eclipse.mylyn.internal.tasks.ui.actions.SynchronizeEditorAction;
Lines 41-46 Link Here
41
import org.eclipse.mylyn.tasks.core.AbstractTask;
42
import org.eclipse.mylyn.tasks.core.AbstractTask;
42
import org.eclipse.mylyn.tasks.core.AbstractTaskCategory;
43
import org.eclipse.mylyn.tasks.core.AbstractTaskCategory;
43
import org.eclipse.mylyn.tasks.core.AbstractTaskContainer;
44
import org.eclipse.mylyn.tasks.core.AbstractTaskContainer;
45
import org.eclipse.mylyn.tasks.core.TaskComment;
44
import org.eclipse.mylyn.tasks.ui.TasksUiPlugin;
46
import org.eclipse.mylyn.tasks.ui.TasksUiPlugin;
45
import org.eclipse.mylyn.tasks.ui.editors.AbstractRepositoryTaskEditor;
47
import org.eclipse.mylyn.tasks.ui.editors.AbstractRepositoryTaskEditor;
46
import org.eclipse.mylyn.tasks.ui.editors.NewTaskEditorInput;
48
import org.eclipse.mylyn.tasks.ui.editors.NewTaskEditorInput;
Lines 96-101 Link Here
96
98
97
	private GlobalAction selectAllAction;
99
	private GlobalAction selectAllAction;
98
100
101
	private NewBugFromCommentAction newBugFromCommentAction = new NewBugFromCommentAction();
102
99
	public TaskEditorActionContributor() {
103
	public TaskEditorActionContributor() {
100
104
101
		cutAction = new GlobalAction(ActionFactory.CUT.getId());
105
		cutAction = new GlobalAction(ActionFactory.CUT.getId());
Lines 162-169 Link Here
162
	}
166
	}
163
167
164
	public void contextMenuAboutToShow(IMenuManager manager, boolean addClipboard) {
168
	public void contextMenuAboutToShow(IMenuManager manager, boolean addClipboard) {
165
		if (editor != null)
169
		if (editor != null) {
166
			updateSelectableActions(editor.getSelection());
170
			updateSelectableActions(editor.getSelection());
171
		}
167
		if (addClipboard) {
172
		if (addClipboard) {
168
			addClipboardActions(manager);
173
			addClipboardActions(manager);
169
		}
174
		}
Lines 213-218 Link Here
213
			manager.add(openWithBrowserAction);
218
			manager.add(openWithBrowserAction);
214
			manager.add(attachFileAction);
219
			manager.add(attachFileAction);
215
			manager.add(synchronizeEditorAction);
220
			manager.add(synchronizeEditorAction);
221
			if (this.getEditor().getActivePageInstance() instanceof AbstractRepositoryTaskEditor) {
222
				if (this.getEditor().getSelection() instanceof RepositoryTaskSelection) {
223
					RepositoryTaskSelection repositoryTaskSelection = (RepositoryTaskSelection) this.getEditor()
224
							.getSelection();
225
					TaskComment comment = repositoryTaskSelection.getComment();
226
					if (comment != null) {
227
						newBugFromCommentAction.setTaskComment(comment);
228
						AbstractRepositoryTaskEditor editor = (AbstractRepositoryTaskEditor) this.getEditor()
229
								.getActivePageInstance();
230
						IEditorInput input = editor.getEditorInput();
231
						if (input instanceof RepositoryTaskEditorInput) {
232
							RepositoryTaskEditorInput repositoryInput = (RepositoryTaskEditorInput) input;
233
							newBugFromCommentAction.setTaskData(repositoryInput.getTaskData());
234
						}
235
						manager.add(newBugFromCommentAction);
236
					}
237
				}
238
			}
216
239
217
			if (task.isActive()) {
240
			if (task.isActive()) {
218
				manager.add(new TaskDeactivateAction() {
241
				manager.add(new TaskDeactivateAction() {
(-)src/org/eclipse/mylyn/tasks/ui/editors/AbstractRepositoryTaskEditor.java (-1 / +19 lines)
Lines 127-132 Link Here
127
import org.eclipse.swt.dnd.FileTransfer;
127
import org.eclipse.swt.dnd.FileTransfer;
128
import org.eclipse.swt.dnd.TextTransfer;
128
import org.eclipse.swt.dnd.TextTransfer;
129
import org.eclipse.swt.dnd.Transfer;
129
import org.eclipse.swt.dnd.Transfer;
130
import org.eclipse.swt.events.FocusEvent;
131
import org.eclipse.swt.events.FocusListener;
130
import org.eclipse.swt.events.ModifyEvent;
132
import org.eclipse.swt.events.ModifyEvent;
131
import org.eclipse.swt.events.ModifyListener;
133
import org.eclipse.swt.events.ModifyListener;
132
import org.eclipse.swt.events.SelectionAdapter;
134
import org.eclipse.swt.events.SelectionAdapter;
Lines 303-308 Link Here
303
305
304
	private boolean ignoreLocationEvents = false;
306
	private boolean ignoreLocationEvents = false;
305
307
308
	private TaskComment selectedComment = null;
309
306
	/**
310
	/**
307
	 * @author Raphael Ackermann (bug 195514)
311
	 * @author Raphael Ackermann (bug 195514)
308
	 */
312
	 */
Lines 347-353 Link Here
347
351
348
		public ISelection getSelection() {
352
		public ISelection getSelection() {
349
			return new RepositoryTaskSelection(taskData.getId(), taskData.getRepositoryUrl(),
353
			return new RepositoryTaskSelection(taskData.getId(), taskData.getRepositoryUrl(),
350
					taskData.getRepositoryKind(), "", true, taskData.getSummary());
354
					taskData.getRepositoryKind(), "", selectedComment, taskData.getSummary());
351
		}
355
		}
352
356
353
		public void removeSelectionChangedListener(ISelectionChangedListener listener) {
357
		public void removeSelectionChangedListener(ISelectionChangedListener listener) {
Lines 2126-2131 Link Here
2126
2130
2127
			TextViewer viewer = addTextViewer(repository, ecComposite, taskComment.getText().trim(), SWT.MULTI
2131
			TextViewer viewer = addTextViewer(repository, ecComposite, taskComment.getText().trim(), SWT.MULTI
2128
					| SWT.WRAP);
2132
					| SWT.WRAP);
2133
2134
			viewer.getTextWidget().addFocusListener(new FocusListener() {
2135
2136
				public void focusGained(FocusEvent e) {
2137
					selectedComment = taskComment;
2138
2139
				}
2140
2141
				public void focusLost(FocusEvent e) {
2142
					selectedComment = null;
2143
2144
				}
2145
			});
2146
2129
			// viewer.getControl().setBackground(new
2147
			// viewer.getControl().setBackground(new
2130
			// Color(expandableComposite.getDisplay(), 123, 34, 155));
2148
			// Color(expandableComposite.getDisplay(), 123, 34, 155));
2131
			StyledText styledText = viewer.getTextWidget();
2149
			StyledText styledText = viewer.getTextWidget();
(-).refactorings/2007/10/43/refactorings.index (+1 lines)
Lines 3-5 Link Here
3
1193174879973	Extract constant 'ID_CONTEXT_TASK_EDITOR'
3
1193174879973	Extract constant 'ID_CONTEXT_TASK_EDITOR'
4
1193174898497	Rename field 'ID_CONTEXT_TEXT_EDITOR'
4
1193174898497	Rename field 'ID_CONTEXT_TEXT_EDITOR'
5
1193174960220	Rename field 'ID_CONTEXT_TASK_EDITOR'
5
1193174960220	Rename field 'ID_CONTEXT_TASK_EDITOR'
6
1193348675861	Delete element
(-).refactorings/2007/10/43/refactorings.history (-1 / +1 lines)
Lines 1-3 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
1
<?xml version="1.0" encoding="UTF-8"?>
2
<session version="1.0">&#x0A;<refactoring comment="Convert anonymous class &apos;org.eclipse.mylyn.tasks.ui.editors.TaskTextViewerConfiguration.getHyperlinkPresenter().new DefaultHyperlinkPresenter() {...}&apos; in &apos;org.eclipse.mylyn.tasks.ui.editors.TaskTextViewerConfiguration.getHyperlinkPresenter()&apos; to nested class&#x0D;&#x0A;- Original project: &apos;org.eclipse.mylyn.tasks.ui&apos;&#x0D;&#x0A;- Original element: &apos;org.eclipse.mylyn.tasks.ui.editors.TaskTextViewerConfiguration.getHyperlinkPresenter().new DefaultHyperlinkPresenter() {...}&apos;&#x0D;&#x0A;- Class name: &apos;TaskTextViewerHyperlinkPresenter&apos;&#x0D;&#x0A;- Declared visibility: &apos;private&apos;&#x0D;&#x0A;- Declare class &apos;final&apos;" description="Convert anonymous class to nested" final="true" flags="786434" id="org.eclipse.jdt.ui.convert.anonymous" input="/src&lt;org.eclipse.mylyn.tasks.ui.editors{TaskTextViewerConfiguration.java" name="TaskTextViewerHyperlinkPresenter" selection="4293 0" stamp="1193174682888" static="false" version="1.0" visibility="2"/>&#x0A;<refactoring comment="Extract constant &apos;org.eclipse.mylyn.tasks.ui.editors.TaskTextViewerConfiguration.ID_CONTEXT_TEXT_EDITOR&apos; from expression &apos;&quot;org.eclipse.ui.DefaultTextEditor&quot;&apos;&#x0D;&#x0A;- Original project: &apos;org.eclipse.mylyn.tasks.ui&apos;&#x0D;&#x0A;- Constant name: &apos;ID_CONTEXT_TEXT_EDITOR&apos;&#x0D;&#x0A;- Constant expression: &apos;&quot;org.eclipse.ui.DefaultTextEditor&quot;&apos;&#x0D;&#x0A;- Declared visibility: &apos;private&apos;&#x0D;&#x0A;- Replace occurrences of expression with constant" description="Extract constant &apos;ID_CONTEXT_TEXT_EDITOR&apos;" flags="786432" id="org.eclipse.jdt.ui.extract.constant" input="/src&lt;org.eclipse.mylyn.tasks.ui.editors{TaskTextViewerConfiguration.java" name="ID_CONTEXT_TEXT_EDITOR" qualify="false" replace="true" selection="3680 34" stamp="1193174853749" version="1.0" visibility="2"/>&#x0A;<refactoring comment="Extract constant &apos;org.eclipse.mylyn.tasks.ui.editors.TaskTextViewerConfiguration.ID_CONTEXT_TASK_EDITOR&apos; from expression &apos;&quot;org.eclipse.mylyn.tasks.ui.TaskEditor&quot;&apos;&#x0D;&#x0A;- Original project: &apos;org.eclipse.mylyn.tasks.ui&apos;&#x0D;&#x0A;- Constant name: &apos;ID_CONTEXT_TASK_EDITOR&apos;&#x0D;&#x0A;- Constant expression: &apos;&quot;org.eclipse.mylyn.tasks.ui.TaskEditor&quot;&apos;&#x0D;&#x0A;- Declared visibility: &apos;private&apos;&#x0D;&#x0A;- Replace occurrences of expression with constant" description="Extract constant &apos;ID_CONTEXT_TASK_EDITOR&apos;" flags="786432" id="org.eclipse.jdt.ui.extract.constant" input="/src&lt;org.eclipse.mylyn.tasks.ui.editors{TaskTextViewerConfiguration.java" name="ID_CONTEXT_TASK_EDITOR" qualify="false" replace="true" selection="3822 39" stamp="1193174879973" version="1.0" visibility="2"/>&#x0A;<refactoring comment="Rename field &apos;ID_CONTEXT_TEXT_EDITOR&apos; in &apos;org.eclipse.mylyn.tasks.ui.editors.TaskTextViewerConfiguration&apos; to &apos;ID_CONTEXT_EDITOR_TEXT&apos;&#x0D;&#x0A;- Original project: &apos;org.eclipse.mylyn.tasks.ui&apos;&#x0D;&#x0A;- Original element: &apos;org.eclipse.mylyn.tasks.ui.editors.TaskTextViewerConfiguration.ID_CONTEXT_TEXT_EDITOR&apos;&#x0D;&#x0A;- Renamed element: &apos;org.eclipse.mylyn.tasks.ui.editors.TaskTextViewerConfiguration.ID_CONTEXT_EDITOR_TEXT&apos;&#x0D;&#x0A;- Update references to refactored element&#x0D;&#x0A;- Update textual occurrences in comments and strings&#x0D;&#x0A;- Rename getter method for field&#x0D;&#x0A;- Rename setter method for field" delegate="false" deprecate="false" description="Rename field &apos;ID_CONTEXT_TEXT_EDITOR&apos;" flags="589826" getter="true" id="org.eclipse.jdt.ui.rename.field" input="/src&lt;org.eclipse.mylyn.tasks.ui.editors{TaskTextViewerConfiguration.java[TaskTextViewerConfiguration^ID_CONTEXT_TEXT_EDITOR" name="ID_CONTEXT_EDITOR_TEXT" references="true" setter="true" stamp="1193174898497" textual="false" version="1.0"/>&#x0A;<refactoring comment="Rename field &apos;ID_CONTEXT_TASK_EDITOR&apos; in &apos;org.eclipse.mylyn.tasks.ui.editors.TaskTextViewerConfiguration&apos; to &apos;ID_CONTEXT_EDITOR_TASK&apos;&#x0D;&#x0A;- Original project: &apos;org.eclipse.mylyn.tasks.ui&apos;&#x0D;&#x0A;- Original element: &apos;org.eclipse.mylyn.tasks.ui.editors.TaskTextViewerConfiguration.ID_CONTEXT_TASK_EDITOR&apos;&#x0D;&#x0A;- Renamed element: &apos;org.eclipse.mylyn.tasks.ui.editors.TaskTextViewerConfiguration.ID_CONTEXT_EDITOR_TASK&apos;&#x0D;&#x0A;- Update references to refactored element&#x0D;&#x0A;- Update textual occurrences in comments and strings&#x0D;&#x0A;- Rename getter method for field&#x0D;&#x0A;- Rename setter method for field" delegate="false" deprecate="false" description="Rename field &apos;ID_CONTEXT_TASK_EDITOR&apos;" flags="589826" getter="true" id="org.eclipse.jdt.ui.rename.field" input="/src&lt;org.eclipse.mylyn.tasks.ui.editors{TaskTextViewerConfiguration.java[TaskTextViewerConfiguration^ID_CONTEXT_TASK_EDITOR" name="ID_CONTEXT_EDITOR_TASK" references="true" setter="true" stamp="1193174960220" textual="false" version="1.0"/>
2
<session version="1.0">&#x0A;<refactoring comment="Convert anonymous class &apos;org.eclipse.mylyn.tasks.ui.editors.TaskTextViewerConfiguration.getHyperlinkPresenter().new DefaultHyperlinkPresenter() {...}&apos; in &apos;org.eclipse.mylyn.tasks.ui.editors.TaskTextViewerConfiguration.getHyperlinkPresenter()&apos; to nested class&#x0D;&#x0A;- Original project: &apos;org.eclipse.mylyn.tasks.ui&apos;&#x0D;&#x0A;- Original element: &apos;org.eclipse.mylyn.tasks.ui.editors.TaskTextViewerConfiguration.getHyperlinkPresenter().new DefaultHyperlinkPresenter() {...}&apos;&#x0D;&#x0A;- Class name: &apos;TaskTextViewerHyperlinkPresenter&apos;&#x0D;&#x0A;- Declared visibility: &apos;private&apos;&#x0D;&#x0A;- Declare class &apos;final&apos;" description="Convert anonymous class to nested" final="true" flags="786434" id="org.eclipse.jdt.ui.convert.anonymous" input="/src&lt;org.eclipse.mylyn.tasks.ui.editors{TaskTextViewerConfiguration.java" name="TaskTextViewerHyperlinkPresenter" selection="4293 0" stamp="1193174682888" static="false" version="1.0" visibility="2"/>&#x0A;<refactoring comment="Extract constant &apos;org.eclipse.mylyn.tasks.ui.editors.TaskTextViewerConfiguration.ID_CONTEXT_TEXT_EDITOR&apos; from expression &apos;&quot;org.eclipse.ui.DefaultTextEditor&quot;&apos;&#x0D;&#x0A;- Original project: &apos;org.eclipse.mylyn.tasks.ui&apos;&#x0D;&#x0A;- Constant name: &apos;ID_CONTEXT_TEXT_EDITOR&apos;&#x0D;&#x0A;- Constant expression: &apos;&quot;org.eclipse.ui.DefaultTextEditor&quot;&apos;&#x0D;&#x0A;- Declared visibility: &apos;private&apos;&#x0D;&#x0A;- Replace occurrences of expression with constant" description="Extract constant &apos;ID_CONTEXT_TEXT_EDITOR&apos;" flags="786432" id="org.eclipse.jdt.ui.extract.constant" input="/src&lt;org.eclipse.mylyn.tasks.ui.editors{TaskTextViewerConfiguration.java" name="ID_CONTEXT_TEXT_EDITOR" qualify="false" replace="true" selection="3680 34" stamp="1193174853749" version="1.0" visibility="2"/>&#x0A;<refactoring comment="Extract constant &apos;org.eclipse.mylyn.tasks.ui.editors.TaskTextViewerConfiguration.ID_CONTEXT_TASK_EDITOR&apos; from expression &apos;&quot;org.eclipse.mylyn.tasks.ui.TaskEditor&quot;&apos;&#x0D;&#x0A;- Original project: &apos;org.eclipse.mylyn.tasks.ui&apos;&#x0D;&#x0A;- Constant name: &apos;ID_CONTEXT_TASK_EDITOR&apos;&#x0D;&#x0A;- Constant expression: &apos;&quot;org.eclipse.mylyn.tasks.ui.TaskEditor&quot;&apos;&#x0D;&#x0A;- Declared visibility: &apos;private&apos;&#x0D;&#x0A;- Replace occurrences of expression with constant" description="Extract constant &apos;ID_CONTEXT_TASK_EDITOR&apos;" flags="786432" id="org.eclipse.jdt.ui.extract.constant" input="/src&lt;org.eclipse.mylyn.tasks.ui.editors{TaskTextViewerConfiguration.java" name="ID_CONTEXT_TASK_EDITOR" qualify="false" replace="true" selection="3822 39" stamp="1193174879973" version="1.0" visibility="2"/>&#x0A;<refactoring comment="Rename field &apos;ID_CONTEXT_TEXT_EDITOR&apos; in &apos;org.eclipse.mylyn.tasks.ui.editors.TaskTextViewerConfiguration&apos; to &apos;ID_CONTEXT_EDITOR_TEXT&apos;&#x0D;&#x0A;- Original project: &apos;org.eclipse.mylyn.tasks.ui&apos;&#x0D;&#x0A;- Original element: &apos;org.eclipse.mylyn.tasks.ui.editors.TaskTextViewerConfiguration.ID_CONTEXT_TEXT_EDITOR&apos;&#x0D;&#x0A;- Renamed element: &apos;org.eclipse.mylyn.tasks.ui.editors.TaskTextViewerConfiguration.ID_CONTEXT_EDITOR_TEXT&apos;&#x0D;&#x0A;- Update references to refactored element&#x0D;&#x0A;- Update textual occurrences in comments and strings&#x0D;&#x0A;- Rename getter method for field&#x0D;&#x0A;- Rename setter method for field" delegate="false" deprecate="false" description="Rename field &apos;ID_CONTEXT_TEXT_EDITOR&apos;" flags="589826" getter="true" id="org.eclipse.jdt.ui.rename.field" input="/src&lt;org.eclipse.mylyn.tasks.ui.editors{TaskTextViewerConfiguration.java[TaskTextViewerConfiguration^ID_CONTEXT_TEXT_EDITOR" name="ID_CONTEXT_EDITOR_TEXT" references="true" setter="true" stamp="1193174898497" textual="false" version="1.0"/>&#x0A;<refactoring comment="Rename field &apos;ID_CONTEXT_TASK_EDITOR&apos; in &apos;org.eclipse.mylyn.tasks.ui.editors.TaskTextViewerConfiguration&apos; to &apos;ID_CONTEXT_EDITOR_TASK&apos;&#x0D;&#x0A;- Original project: &apos;org.eclipse.mylyn.tasks.ui&apos;&#x0D;&#x0A;- Original element: &apos;org.eclipse.mylyn.tasks.ui.editors.TaskTextViewerConfiguration.ID_CONTEXT_TASK_EDITOR&apos;&#x0D;&#x0A;- Renamed element: &apos;org.eclipse.mylyn.tasks.ui.editors.TaskTextViewerConfiguration.ID_CONTEXT_EDITOR_TASK&apos;&#x0D;&#x0A;- Update references to refactored element&#x0D;&#x0A;- Update textual occurrences in comments and strings&#x0D;&#x0A;- Rename getter method for field&#x0D;&#x0A;- Rename setter method for field" delegate="false" deprecate="false" description="Rename field &apos;ID_CONTEXT_TASK_EDITOR&apos;" flags="589826" getter="true" id="org.eclipse.jdt.ui.rename.field" input="/src&lt;org.eclipse.mylyn.tasks.ui.editors{TaskTextViewerConfiguration.java[TaskTextViewerConfiguration^ID_CONTEXT_TASK_EDITOR" name="ID_CONTEXT_EDITOR_TASK" references="true" setter="true" stamp="1193174960220" textual="false" version="1.0"/>&#x0A;<refactoring accessors="true" comment="Delete 1 element(s) from project &apos;org.eclipse.mylyn.tasks.ui&apos;&#x0D;&#x0A;- Original project: &apos;org.eclipse.mylyn.tasks.ui&apos;&#x0D;&#x0A;- Original element: &apos;AbstractRepositoryTaskEditor.java.rej&apos;" description="Delete element" element1="src/org/eclipse/mylyn/tasks/ui/editors/AbstractRepositoryTaskEditor.java.rej" elements="0" flags="589830" id="org.eclipse.jdt.ui.delete" resources="1" stamp="1193348675861" subPackages="false" version="1.0"/>
3
</session>
3
</session>
(-)src/org/eclipse/mylyn/internal/tasks/ui/actions/NewBugFromCommentAction.java (+110 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.internal.tasks.ui.actions;
10
11
import org.eclipse.jface.action.Action;
12
import org.eclipse.jface.action.IAction;
13
import org.eclipse.jface.dialogs.MessageDialog;
14
import org.eclipse.jface.wizard.WizardDialog;
15
import org.eclipse.mylyn.internal.tasks.ui.ITasksUiConstants;
16
import org.eclipse.mylyn.internal.tasks.ui.TasksUiImages;
17
import org.eclipse.mylyn.internal.tasks.ui.wizards.NewTaskWizard;
18
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
19
import org.eclipse.mylyn.tasks.core.RepositoryTaskData;
20
import org.eclipse.mylyn.tasks.core.TaskComment;
21
import org.eclipse.mylyn.tasks.core.TaskRepositoryManager;
22
import org.eclipse.mylyn.tasks.ui.TasksUiPlugin;
23
import org.eclipse.mylyn.tasks.ui.editors.AbstractRepositoryTaskEditor;
24
import org.eclipse.mylyn.tasks.ui.editors.TaskEditor;
25
import org.eclipse.swt.SWT;
26
import org.eclipse.swt.dnd.Clipboard;
27
import org.eclipse.swt.dnd.TextTransfer;
28
import org.eclipse.swt.dnd.Transfer;
29
import org.eclipse.swt.widgets.Shell;
30
import org.eclipse.ui.IWorkbenchPage;
31
import org.eclipse.ui.PlatformUI;
32
33
/**
34
 * @author Frank Becker
35
 */
36
public class NewBugFromCommentAction extends Action {
37
38
	private static final String LABEL = "New Task from Comment";
39
40
	public static final String ID = "org.eclipse.mylyn.tasklist.actions.CreateNewFromComment";
41
42
	private TaskComment taskComment;
43
44
	protected RepositoryTaskData taskData;
45
46
	public NewBugFromCommentAction() {
47
		super(LABEL);
48
		setId(ID);
49
		setImageDescriptor(TasksUiImages.TASK_NEW);
50
51
		setAccelerator(SWT.MOD1 + SWT.MOD2 + 'n');
52
	}
53
54
	public void run(IAction action) {
55
		run();
56
	}
57
58
	@Override
59
	public void run() {
60
		NewTaskWizard wizard = new NewTaskWizard();
61
		Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
62
		if (shell != null && !shell.isDisposed()) {
63
			WizardDialog dialog = new WizardDialog(shell, wizard);
64
			dialog.setBlockOnOpen(true);
65
			if (dialog.open() == WizardDialog.CANCEL) {
66
				return;
67
			}
68
69
			IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
70
			AbstractRepositoryTaskEditor editor = null;
71
			String summary = "";
72
73
			AbstractRepositoryConnector connector = null;
74
			TaskRepositoryManager repositoryManager = TasksUiPlugin.getRepositoryManager();
75
			connector = repositoryManager.getRepositoryConnector(taskData.getRepositoryKind());
76
77
			String description = "From task: " + connector.getTaskUrl(taskData.getRepositoryUrl(), taskData.getId())
78
					+ " comment#" + taskComment.getNumber() + "\n\noriginal-comment:\n" + taskComment.getText();
79
80
			try {
81
				TaskEditor taskEditor = (TaskEditor) page.getActiveEditor();
82
				editor = (AbstractRepositoryTaskEditor) taskEditor.getActivePageInstance();
83
			} catch (ClassCastException err) {
84
				Clipboard clipboard = new Clipboard(page.getWorkbenchWindow().getShell().getDisplay());
85
				clipboard.setContents(new Object[] { summary + "\n" + description },
86
						new Transfer[] { TextTransfer.getInstance() });
87
88
				MessageDialog.openInformation(
89
						page.getWorkbenchWindow().getShell(),
90
						ITasksUiConstants.TITLE_DIALOG,
91
						"This connector does not provide a rich task editor for creating tasks.\n\n"
92
								+ "The error contents have been placed in the clipboard so that you can paste them into the entry form.");
93
				return;
94
			}
95
96
			editor.setSummaryText(summary);
97
			editor.setDescriptionText(description);
98
99
		}
100
	}
101
102
	public void setTaskComment(TaskComment taskComment) {
103
		this.taskComment = taskComment;
104
	}
105
106
	public void setTaskData(RepositoryTaskData taskData) {
107
		this.taskData = taskData;
108
	}
109
110
}

Return to bug 169426