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/tasks/ui/editors/AbstractRepositoryTaskEditor.java (-5 / +55 lines)
Lines 78-83 Link Here
78
import org.eclipse.mylyn.internal.tasks.ui.actions.AttachScreenshotAction;
78
import org.eclipse.mylyn.internal.tasks.ui.actions.AttachScreenshotAction;
79
import org.eclipse.mylyn.internal.tasks.ui.actions.CopyAttachmentToClipboardJob;
79
import org.eclipse.mylyn.internal.tasks.ui.actions.CopyAttachmentToClipboardJob;
80
import org.eclipse.mylyn.internal.tasks.ui.actions.DownloadAttachmentJob;
80
import org.eclipse.mylyn.internal.tasks.ui.actions.DownloadAttachmentJob;
81
import org.eclipse.mylyn.internal.tasks.ui.actions.NewBugFromCommentAction;
81
import org.eclipse.mylyn.internal.tasks.ui.actions.SynchronizeEditorAction;
82
import org.eclipse.mylyn.internal.tasks.ui.actions.SynchronizeEditorAction;
82
import org.eclipse.mylyn.internal.tasks.ui.actions.ToggleTaskActivationAction;
83
import org.eclipse.mylyn.internal.tasks.ui.actions.ToggleTaskActivationAction;
83
import org.eclipse.mylyn.internal.tasks.ui.editors.AttachmentTableLabelProvider;
84
import org.eclipse.mylyn.internal.tasks.ui.editors.AttachmentTableLabelProvider;
Lines 126-131 Link Here
126
import org.eclipse.swt.dnd.FileTransfer;
127
import org.eclipse.swt.dnd.FileTransfer;
127
import org.eclipse.swt.dnd.TextTransfer;
128
import org.eclipse.swt.dnd.TextTransfer;
128
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;
129
import org.eclipse.swt.events.ModifyEvent;
132
import org.eclipse.swt.events.ModifyEvent;
130
import org.eclipse.swt.events.ModifyListener;
133
import org.eclipse.swt.events.ModifyListener;
131
import org.eclipse.swt.events.SelectionAdapter;
134
import org.eclipse.swt.events.SelectionAdapter;
Lines 300-305 Link Here
300
303
301
	private boolean ignoreLocationEvents = false;
304
	private boolean ignoreLocationEvents = false;
302
305
306
	private static final String LABEL_NEW_BUG = "Create New Bug";
307
303
	/**
308
	/**
304
	 * @author Raphael Ackermann (bug 195514)
309
	 * @author Raphael Ackermann (bug 195514)
305
	 */
310
	 */
Lines 859-865 Link Here
859
	protected Composite createAttributeSection() {
864
	protected Composite createAttributeSection() {
860
		attributesSection = createSection(editorComposite, getSectionLabel(SECTION_NAME.ATTRIBTUES_SECTION));
865
		attributesSection = createSection(editorComposite, getSectionLabel(SECTION_NAME.ATTRIBTUES_SECTION));
861
		attributesSection.setExpanded(expandedStateAttributes || hasAttributeChanges);
866
		attributesSection.setExpanded(expandedStateAttributes || hasAttributeChanges);
862
		
867
863
		Composite toolbarComposite = toolkit.createComposite(attributesSection);
868
		Composite toolbarComposite = toolkit.createComposite(attributesSection);
864
		toolbarComposite.setBackground(null);
869
		toolbarComposite.setBackground(null);
865
		RowLayout rowLayout = new RowLayout();
870
		RowLayout rowLayout = new RowLayout();
Lines 937-946 Link Here
937
		attributesData.horizontalSpan = 1;
942
		attributesData.horizontalSpan = 1;
938
		attributesData.grabExcessVerticalSpace = false;
943
		attributesData.grabExcessVerticalSpace = false;
939
		attribComp.setLayoutData(attributesData);
944
		attribComp.setLayoutData(attributesData);
940
		
945
941
		return attribComp;
946
		return attribComp;
942
	}
947
	}
943
	
948
944
	/**
949
	/**
945
	 * Creates the attribute section, which contains most of the basic attributes of the task (some of which are
950
	 * Creates the attribute section, which contains most of the basic attributes of the task (some of which are
946
	 * editable).
951
	 * editable).
Lines 1507-1514 Link Here
1507
		Button attachFileButton = toolkit.createButton(attachmentControlsComposite, "Add File...", SWT.PUSH);
1512
		Button attachFileButton = toolkit.createButton(attachmentControlsComposite, "Add File...", SWT.PUSH);
1508
		attachFileButton.setImage(WorkbenchImages.getImage(ISharedImages.IMG_OBJ_FILE));
1513
		attachFileButton.setImage(WorkbenchImages.getImage(ISharedImages.IMG_OBJ_FILE));
1509
1514
1510
		Button attachScreenshotButton = toolkit.createButton(attachmentControlsComposite, "Add Screenshot...",
1515
		Button attachScreenshotButton = toolkit.createButton(attachmentControlsComposite, "Add Screenshot...", SWT.PUSH);
1511
				SWT.PUSH);
1512
		attachScreenshotButton.setImage(TasksUiImages.getImage(TasksUiImages.IMAGE_CAPTURE));
1516
		attachScreenshotButton.setImage(TasksUiImages.getImage(TasksUiImages.IMAGE_CAPTURE));
1513
1517
1514
		final AbstractTask task = TasksUiPlugin.getTaskListManager().getTaskList().getTask(repository.getUrl(),
1518
		final AbstractTask task = TasksUiPlugin.getTaskListManager().getTaskList().getTask(repository.getUrl(),
Lines 1715-1720 Link Here
1715
		return replyLink;
1719
		return replyLink;
1716
	}
1720
	}
1717
1721
1722
	public ImageHyperlink createNewBugHyperlink(Composite composite, final TaskComment taskComment) {
1723
		final ImageHyperlink newLink = new ImageHyperlink(composite, SWT.NULL);
1724
		toolkit.adapt(newLink, true, true);
1725
		newLink.setImage(TasksUiImages.getImage(TasksUiImages.TASK_NEW));
1726
		newLink.setToolTipText(LABEL_NEW_BUG);
1727
		// no need for the background - transparency will take care of it
1728
		newLink.setBackground(null);
1729
		// replyLink.setBackground(section.getTitleBarGradientBackground());
1730
		newLink.addHyperlinkListener(new HyperlinkAdapter() {
1731
			public void linkActivated(HyperlinkEvent e) {
1732
				NewBugFromCommentAction newBugFromCommentAction = new NewBugFromCommentAction();
1733
				newBugFromCommentAction.setTaskComment(taskComment);
1734
				newBugFromCommentAction.setTaskData(taskData);
1735
				newBugFromCommentAction.run();
1736
			}
1737
		});
1738
		return newLink;
1739
	}
1740
1718
	protected void addDuplicateDetection(Composite composite) {
1741
	protected void addDuplicateDetection(Composite composite) {
1719
		List<AbstractDuplicateDetector> allCollectors = new ArrayList<AbstractDuplicateDetector>();
1742
		List<AbstractDuplicateDetector> allCollectors = new ArrayList<AbstractDuplicateDetector>();
1720
		if (getDuplicateSearchCollectorsList() != null) {
1743
		if (getDuplicateSearchCollectorsList() != null) {
Lines 1914-1919 Link Here
1914
		}
1937
		}
1915
	}
1938
	}
1916
1939
1940
	protected TaskComment selectedTaskComment;
1941
1942
	protected class CommentFocusListener implements FocusListener {
1943
		private TaskComment taskComment;
1944
1945
		public CommentFocusListener(TaskComment taskComment) {
1946
			this.taskComment = taskComment;
1947
		}
1948
1949
		public void focusGained(FocusEvent e) {
1950
			selectedTaskComment = taskComment;
1951
		}
1952
1953
		public void focusLost(FocusEvent e) {
1954
			selectedTaskComment = null;
1955
		}
1956
	}
1957
1958
	public TaskComment getSelectedTaskComment() {
1959
		return selectedTaskComment;
1960
	}
1961
1917
	protected boolean supportsCommentDelete() {
1962
	protected boolean supportsCommentDelete() {
1918
		return false;
1963
		return false;
1919
	}
1964
	}
Lines 2061-2066 Link Here
2061
			final ImageHyperlink replyLink = createReplyHyperlink(taskComment.getNumber(), toolbarButtonComp,
2106
			final ImageHyperlink replyLink = createReplyHyperlink(taskComment.getNumber(), toolbarButtonComp,
2062
					taskComment.getText());
2107
					taskComment.getText());
2063
2108
2109
			final ImageHyperlink newLink = createNewBugHyperlink(toolbarButtonComp, taskComment);
2110
2064
			expandableComposite.addExpansionListener(new ExpansionAdapter() {
2111
			expandableComposite.addExpansionListener(new ExpansionAdapter() {
2065
2112
2066
				@Override
2113
				@Override
Lines 2083-2094 Link Here
2083
				@Override
2130
				@Override
2084
				public void linkEntered(HyperlinkEvent e) {
2131
				public void linkEntered(HyperlinkEvent e) {
2085
					replyLink.setUnderlined(true);
2132
					replyLink.setUnderlined(true);
2133
					newLink.setUnderlined(true);
2086
					super.linkEntered(e);
2134
					super.linkEntered(e);
2087
				}
2135
				}
2088
2136
2089
				@Override
2137
				@Override
2090
				public void linkExited(HyperlinkEvent e) {
2138
				public void linkExited(HyperlinkEvent e) {
2091
					replyLink.setUnderlined(false);
2139
					replyLink.setUnderlined(false);
2140
					newLink.setUnderlined(false);
2092
					super.linkExited(e);
2141
					super.linkExited(e);
2093
				}
2142
				}
2094
			});
2143
			});
Lines 2125-2130 Link Here
2125
			// code for outline
2174
			// code for outline
2126
			commentStyleText.add(styledText);
2175
			commentStyleText.add(styledText);
2127
			controlBySelectableObject.put(taskComment, styledText);
2176
			controlBySelectableObject.put(taskComment, styledText);
2177
			styledText.addFocusListener(new CommentFocusListener(taskComment));
2128
2178
2129
			// if (supportsCommentDelete()) {
2179
			// if (supportsCommentDelete()) {
2130
			// Button deleteButton = toolkit.createButton(ecComposite, null,
2180
			// Button deleteButton = toolkit.createButton(ecComposite, null,
(-)src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorActionContributor.java (-1 / +19 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 96-101 Link Here
96
97
97
	private GlobalAction selectAllAction;
98
	private GlobalAction selectAllAction;
98
99
100
	private NewBugFromCommentAction newBugFromCommentAction = new NewBugFromCommentAction();
101
99
	public TaskEditorActionContributor() {
102
	public TaskEditorActionContributor() {
100
103
101
		cutAction = new GlobalAction(ActionFactory.CUT.getId());
104
		cutAction = new GlobalAction(ActionFactory.CUT.getId());
Lines 162-169 Link Here
162
	}
165
	}
163
166
164
	public void contextMenuAboutToShow(IMenuManager manager, boolean addClipboard) {
167
	public void contextMenuAboutToShow(IMenuManager manager, boolean addClipboard) {
165
		if (editor != null)
168
		if (editor != null) {
166
			updateSelectableActions(editor.getSelection());
169
			updateSelectableActions(editor.getSelection());
170
		}
167
		if (addClipboard) {
171
		if (addClipboard) {
168
			addClipboardActions(manager);
172
			addClipboardActions(manager);
169
		}
173
		}
Lines 213-218 Link Here
213
			manager.add(openWithBrowserAction);
217
			manager.add(openWithBrowserAction);
214
			manager.add(attachFileAction);
218
			manager.add(attachFileAction);
215
			manager.add(synchronizeEditorAction);
219
			manager.add(synchronizeEditorAction);
220
			if (this.getEditor().getActivePageInstance() instanceof AbstractRepositoryTaskEditor) {
221
				AbstractRepositoryTaskEditor abstractRepositoryTaskEditor = (AbstractRepositoryTaskEditor) this.getEditor()
222
						.getActivePageInstance();
223
				if (abstractRepositoryTaskEditor.getSelectedTaskComment() != null) {
224
					System.out.println("Comment selected");
225
					newBugFromCommentAction.setTaskComment(abstractRepositoryTaskEditor.getSelectedTaskComment());
226
					IEditorInput input = abstractRepositoryTaskEditor.getEditorInput();
227
					if (input instanceof RepositoryTaskEditorInput) {
228
						RepositoryTaskEditorInput repositoryInput = (RepositoryTaskEditorInput) input;
229
						newBugFromCommentAction.setTaskData(repositoryInput.getTaskData());
230
					}
231
					manager.add(newBugFromCommentAction);
232
				}
233
			}
216
234
217
			if (task.isActive()) {
235
			if (task.isActive()) {
218
				manager.add(new TaskDeactivateAction() {
236
				manager.add(new TaskDeactivateAction() {
(-)src/org/eclipse/mylyn/internal/tasks/ui/actions/NewBugFromCommentAction.java (+106 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
public class NewBugFromCommentAction extends Action {
34
35
	private static final String LABEL = "New Task from Comment";
36
37
	public static final String ID = "org.eclipse.mylyn.tasklist.actions.CreateNewFromComment";
38
39
	private TaskComment taskComment;
40
	protected RepositoryTaskData taskData;
41
42
	
43
	public NewBugFromCommentAction() {
44
		super(LABEL);
45
		setId(ID);
46
		setImageDescriptor(TasksUiImages.TASK_NEW);
47
48
		setAccelerator(SWT.MOD1 + SWT.MOD2 + 'n');
49
	}
50
51
	public void run(IAction action) {
52
		run();
53
	}
54
	
55
	@Override
56
	public void run() {
57
		NewTaskWizard wizard = new NewTaskWizard();
58
		Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
59
		if (shell != null && !shell.isDisposed()) {
60
			WizardDialog dialog = new WizardDialog(shell, wizard);
61
			dialog.setBlockOnOpen(true);
62
			if (dialog.open() == WizardDialog.CANCEL) {
63
				return;
64
			}
65
66
			IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
67
			AbstractRepositoryTaskEditor editor = null;
68
			String summary = "";
69
			
70
			AbstractRepositoryConnector connector = null;
71
			TaskRepositoryManager repositoryManager = TasksUiPlugin.getRepositoryManager();					
72
			connector = repositoryManager.getRepositoryConnector(taskData.getRepositoryKind());
73
74
			String description = "created from " + connector.getTaskUrl(taskData.getRepositoryUrl(),  taskData.getId()) + " comment#" + taskComment.getNumber() 
75
			+ "\n\noriginal-comment:\n" + taskComment.getText();
76
			
77
			try {
78
				TaskEditor taskEditor = (TaskEditor) page.getActiveEditor();
79
				editor = (AbstractRepositoryTaskEditor) taskEditor.getActivePageInstance();
80
			} catch (ClassCastException err) {
81
				Clipboard clipboard = new Clipboard(page.getWorkbenchWindow().getShell().getDisplay());
82
				clipboard.setContents(new Object[] { summary + "\n" + description },
83
						new Transfer[] { TextTransfer.getInstance() });
84
85
				MessageDialog.openInformation(
86
						page.getWorkbenchWindow().getShell(),
87
						ITasksUiConstants.TITLE_DIALOG,								"This connector does not provide a rich task editor for creating tasks.\n\n"
88
								+ "The error contents have been placed in the clipboard so that you can paste them into the entry form.");
89
				return;
90
			}
91
92
			editor.setSummaryText(summary);
93
			editor.setDescriptionText(description);
94
95
		}
96
		}
97
98
	public void setTaskComment(TaskComment taskComment) {
99
		this.taskComment = taskComment;
100
	}
101
102
	public void setTaskData(RepositoryTaskData taskData) {
103
		this.taskData = taskData;
104
	}
105
	
106
}

Return to bug 169426