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/bugzilla/core/BugzillaClient.java (-15 / +50 lines)
Lines 50-55 Link Here
50
import org.eclipse.mylyn.tasks.core.AbstractRepositoryQuery;
50
import org.eclipse.mylyn.tasks.core.AbstractRepositoryQuery;
51
import org.eclipse.mylyn.tasks.core.ITaskAttachment;
51
import org.eclipse.mylyn.tasks.core.ITaskAttachment;
52
import org.eclipse.mylyn.tasks.core.ITaskCollector;
52
import org.eclipse.mylyn.tasks.core.ITaskCollector;
53
import org.eclipse.mylyn.tasks.core.LanguageSettings;
53
import org.eclipse.mylyn.tasks.core.QueryHitCollector;
54
import org.eclipse.mylyn.tasks.core.QueryHitCollector;
54
import org.eclipse.mylyn.tasks.core.RepositoryOperation;
55
import org.eclipse.mylyn.tasks.core.RepositoryOperation;
55
import org.eclipse.mylyn.tasks.core.RepositoryStatus;
56
import org.eclipse.mylyn.tasks.core.RepositoryStatus;
Lines 160-166 Link Here
160
161
161
	private boolean lastModifiedSupported = true;
162
	private boolean lastModifiedSupported = true;
162
163
163
	private BugzillaLanguageSettings languageSettings;
164
	private LanguageSettings languageSettings;
164
165
165
	private class BugzillaRetryHandler extends DefaultHttpMethodRetryHandler {
166
	private class BugzillaRetryHandler extends DefaultHttpMethodRetryHandler {
166
		public BugzillaRetryHandler() {
167
		public BugzillaRetryHandler() {
Lines 183-193 Link Here
183
	public BugzillaClient(URL url, String username, String password, String htAuthUser, String htAuthPass,
184
	public BugzillaClient(URL url, String username, String password, String htAuthUser, String htAuthPass,
184
			String characterEncoding) {
185
			String characterEncoding) {
185
		this(url, username, password, htAuthUser, htAuthPass, characterEncoding, new HashMap<String, String>(),
186
		this(url, username, password, htAuthUser, htAuthPass, characterEncoding, new HashMap<String, String>(),
186
				BugzillaCorePlugin.getLanguageSettings("en"));
187
				BugzillaCorePlugin.getDefault().getLanguageSetting("en"));
187
	}
188
	}
188
189
189
	public BugzillaClient(URL url, String username, String password, String htAuthUser, String htAuthPass,
190
	public BugzillaClient(URL url, String username, String password, String htAuthUser, String htAuthPass,
190
			String characterEncoding, Map<String, String> configParameters, BugzillaLanguageSettings languageSettings) {
191
			String characterEncoding, Map<String, String> configParameters, LanguageSettings languageSettings) {
191
		this.username = username;
192
		this.username = username;
192
		this.password = password;
193
		this.password = password;
193
		this.repositoryUrl = url;
194
		this.repositoryUrl = url;
Lines 835-842 Link Here
835
							&& ((HtmlTag) token.getValue()).getTagType() == HtmlTag.Type.TITLE
836
							&& ((HtmlTag) token.getValue()).getTagType() == HtmlTag.Type.TITLE
836
							&& ((HtmlTag) token.getValue()).isEndTag()) {
837
							&& ((HtmlTag) token.getValue()).isEndTag()) {
837
838
838
						if (!taskData.isNew()
839
						boolean found = false;
839
								&& (title.toLowerCase(Locale.ENGLISH).indexOf(languageSettings.getProcessed()) != -1)) {
840
						for (Iterator<String> iterator = languageSettings.getProcessed().iterator(); iterator.hasNext() && !found;) {
841
							String value = iterator.next().toLowerCase(Locale.ENGLISH);
842
							found = found || title.indexOf(value) != -1;
843
						}
844
845
						if (!taskData.isNew() && found) {
840
							existingBugPosted = true;
846
							existingBugPosted = true;
841
						} else if (taskData.isNew() && prefix != null && prefix2 != null && postfix != null
847
						} else if (taskData.isNew() && prefix != null && prefix2 != null && postfix != null
842
								&& postfix2 != null) {
848
								&& postfix2 != null) {
Lines 1048-1077 Link Here
1048
					} else if (token.getType() == Token.TAG
1054
					} else if (token.getType() == Token.TAG
1049
							&& ((HtmlTag) token.getValue()).getTagType() == HtmlTag.Type.TITLE
1055
							&& ((HtmlTag) token.getValue()).getTagType() == HtmlTag.Type.TITLE
1050
							&& ((HtmlTag) token.getValue()).isEndTag()) {
1056
							&& ((HtmlTag) token.getValue()).isEndTag()) {
1051
1057
						
1052
						if (title.indexOf(languageSettings.getLogin()) != -1
1058
						boolean found = false;
1053
								|| (title.indexOf(languageSettings.getInvalid()) != -1 && title.indexOf(languageSettings.getPassword()) != -1)
1059
						for (Iterator<String> iterator = languageSettings.getErrorLogin().iterator(); iterator.hasNext() && !found;) {
1054
								|| title.indexOf(languageSettings.getCheckEmail()) != -1
1060
							String value = iterator.next().toLowerCase(Locale.ENGLISH);
1055
								|| (languageSettings.getLogin2() != null && title.indexOf(languageSettings.getLogin2()) != -1)) {
1061
							found = found || title.indexOf(value) != -1;
1062
							int i = 12;
1063
							i = i +2;
1064
						}
1065
						if (found) {
1056
							authenticated = false;
1066
							authenticated = false;
1057
							throw new CoreException(new BugzillaStatus(Status.ERROR, BugzillaCorePlugin.PLUGIN_ID,
1067
							throw new CoreException(new BugzillaStatus(Status.ERROR, BugzillaCorePlugin.PLUGIN_ID,
1058
									RepositoryStatus.ERROR_REPOSITORY_LOGIN, repositoryUrl.toString(), title));
1068
									RepositoryStatus.ERROR_REPOSITORY_LOGIN, repositoryUrl.toString(), title));
1059
						} else if (title.indexOf(languageSettings.getMidairCollision()) != -1) {
1069
						}
1070
						found = false;
1071
						for (Iterator<String> iterator = languageSettings.getErrorCollision().iterator(); iterator.hasNext() && !found;) {
1072
							String value = iterator.next().toLowerCase(Locale.ENGLISH);
1073
							found = found || title.indexOf(value) != -1;
1074
						}
1075
						if (found) {
1060
							throw new CoreException(new BugzillaStatus(Status.ERROR, BugzillaCorePlugin.PLUGIN_ID,
1076
							throw new CoreException(new BugzillaStatus(Status.ERROR, BugzillaCorePlugin.PLUGIN_ID,
1061
									RepositoryStatus.REPOSITORY_COLLISION, repositoryUrl.toString()));
1077
									RepositoryStatus.REPOSITORY_COLLISION, repositoryUrl.toString()));
1062
						} else if (title.indexOf(languageSettings.getCommentRequired()) != -1) {
1078
						}
1079
						found = false;
1080
						for (Iterator<String> iterator = languageSettings.getErrorCommentReqired().iterator(); iterator.hasNext() && !found;) {
1081
							String value = iterator.next().toLowerCase(Locale.ENGLISH);
1082
							found = found || title.indexOf(value) != -1;
1083
						}
1084
						if (found) {
1063
							throw new CoreException(new BugzillaStatus(Status.INFO, BugzillaCorePlugin.PLUGIN_ID,
1085
							throw new CoreException(new BugzillaStatus(Status.INFO, BugzillaCorePlugin.PLUGIN_ID,
1064
									RepositoryStatus.REPOSITORY_COMMENT_REQUIRED));
1086
									RepositoryStatus.REPOSITORY_COMMENT_REQUIRED));
1065
						} else if (title.indexOf(languageSettings.getLoggedOut()) != -1) {
1087
						}
1088
						found = false;
1089
						for (Iterator<String> iterator = languageSettings.getErrorLoggedOut().iterator(); iterator.hasNext() && !found;) {
1090
							String value = iterator.next().toLowerCase(Locale.ENGLISH);
1091
							found = found || title.indexOf(value) != -1;
1092
						}
1093
						if (found) {
1066
							authenticated = false;
1094
							authenticated = false;
1067
							// throw new
1095
							// throw new
1068
							// BugzillaException(IBugzillaConstants.LOGGED_OUT);
1096
							// BugzillaException(IBugzillaConstants.LOGGED_OUT);
1069
							throw new CoreException(new BugzillaStatus(Status.INFO, BugzillaCorePlugin.PLUGIN_ID,
1097
							throw new CoreException(new BugzillaStatus(Status.INFO, BugzillaCorePlugin.PLUGIN_ID,
1070
									RepositoryStatus.REPOSITORY_LOGGED_OUT,
1098
									RepositoryStatus.REPOSITORY_LOGGED_OUT,
1071
									"You have been logged out. Please retry operation."));
1099
									"You have been logged out. Please retry operation."));
1072
						} else if (title.indexOf(IBugzillaConstants.CHANGES_SUBMITTED) != -1) {
1100
						}
1101
						found = false;
1102
						for (Iterator<String> iterator = languageSettings.getChangesSubmitted().iterator(); iterator.hasNext() && !found;) {
1103
							String value = iterator.next().toLowerCase(Locale.ENGLISH);
1104
							found = found || title.indexOf(value) != -1;
1105
						}
1106
						if (found) {
1073
							return;
1107
							return;
1074
						}
1108
						}
1109
						isTitle = false;
1075
					}
1110
					}
1076
				}
1111
				}
1077
			}
1112
			}
Lines 1100-1106 Link Here
1100
			method = getConnectGzip(url);
1135
			method = getConnectGzip(url);
1101
			if (method != null) {
1136
			if (method != null) {
1102
				BugzillaTaskHistoryParser parser = new BugzillaTaskHistoryParser(
1137
				BugzillaTaskHistoryParser parser = new BugzillaTaskHistoryParser(
1103
						method.getResponseBodyAsUnzippedStream(), characterEncoding);
1138
						method.getResponseBodyAsUnzippedStream(), characterEncoding,languageSettings);
1104
				try {
1139
				try {
1105
					return parser.retrieveHistory();
1140
					return parser.retrieveHistory();
1106
				} catch (LoginException e) {
1141
				} catch (LoginException e) {
(-)src/org/eclipse/mylyn/tasks/ui/editors/TaskFormPage.java (+15 lines)
Lines 665-668 Link Here
665
		}
665
		}
666
	}
666
	}
667
667
668
	public String getSeletedTextFromActualEdit() {
669
		Control focusControl = getFocusControl();
670
		if (focusControl == null)
671
			return null;
672
		if (focusControl instanceof StyledText) {
673
			StyledText text = (StyledText) focusControl;
674
			for (TextViewer viewer : textViewers) {
675
				if (viewer.getTextWidget() == text) {
676
					return text.getSelectionText();
677
				}
678
			}
679
		}
680
		return null;
681
	}
682
668
}
683
}
(-)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();
(-)src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorActionContributor.java (+28 lines)
Lines 33-38 Link Here
33
import org.eclipse.mylyn.internal.tasks.ui.actions.AttachAction;
33
import org.eclipse.mylyn.internal.tasks.ui.actions.AttachAction;
34
import org.eclipse.mylyn.internal.tasks.ui.actions.AttachScreenshotAction;
34
import org.eclipse.mylyn.internal.tasks.ui.actions.AttachScreenshotAction;
35
import org.eclipse.mylyn.internal.tasks.ui.actions.CopyTaskDetailsAction;
35
import org.eclipse.mylyn.internal.tasks.ui.actions.CopyTaskDetailsAction;
36
import org.eclipse.mylyn.internal.tasks.ui.actions.NewBugFromCommentAction;
36
import org.eclipse.mylyn.internal.tasks.ui.actions.OpenWithBrowserAction;
37
import org.eclipse.mylyn.internal.tasks.ui.actions.OpenWithBrowserAction;
37
import org.eclipse.mylyn.internal.tasks.ui.actions.ShowInTaskListAction;
38
import org.eclipse.mylyn.internal.tasks.ui.actions.ShowInTaskListAction;
38
import org.eclipse.mylyn.internal.tasks.ui.actions.SynchronizeEditorAction;
39
import org.eclipse.mylyn.internal.tasks.ui.actions.SynchronizeEditorAction;
Lines 42-47 Link Here
42
import org.eclipse.mylyn.tasks.core.AbstractTask;
43
import org.eclipse.mylyn.tasks.core.AbstractTask;
43
import org.eclipse.mylyn.tasks.core.AbstractTaskCategory;
44
import org.eclipse.mylyn.tasks.core.AbstractTaskCategory;
44
import org.eclipse.mylyn.tasks.core.AbstractTaskContainer;
45
import org.eclipse.mylyn.tasks.core.AbstractTaskContainer;
46
import org.eclipse.mylyn.tasks.core.TaskComment;
45
import org.eclipse.mylyn.tasks.ui.TasksUiPlugin;
47
import org.eclipse.mylyn.tasks.ui.TasksUiPlugin;
46
import org.eclipse.mylyn.tasks.ui.editors.AbstractRepositoryTaskEditor;
48
import org.eclipse.mylyn.tasks.ui.editors.AbstractRepositoryTaskEditor;
47
import org.eclipse.mylyn.tasks.ui.editors.NewTaskEditorInput;
49
import org.eclipse.mylyn.tasks.ui.editors.NewTaskEditorInput;
Lines 98-103 Link Here
98
	private GlobalAction pasteAction;
100
	private GlobalAction pasteAction;
99
101
100
	private GlobalAction selectAllAction;
102
	private GlobalAction selectAllAction;
103
	
104
	private NewBugFromCommentAction newBugFromCommentAction = new NewBugFromCommentAction();
101
105
102
	public TaskEditorActionContributor() {
106
	public TaskEditorActionContributor() {
103
107
Lines 220-225 Link Here
220
			manager.add(synchronizeEditorAction);
224
			manager.add(synchronizeEditorAction);
221
			manager.add(openWithBrowserAction);
225
			manager.add(openWithBrowserAction);
222
			
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
					
233
					if (comment != null) {
234
						newBugFromCommentAction.setTaskComment(comment);
235
						AbstractRepositoryTaskEditor editor = (AbstractRepositoryTaskEditor) this.getEditor()
236
								.getActivePageInstance();
237
						if (getEditor().getActivePageInstance() instanceof TaskFormPage) {
238
							TaskFormPage editor1 = (TaskFormPage) getEditor().getActivePageInstance();
239
							String selText = editor1.getSeletedTextFromActualEdit();
240
							newBugFromCommentAction.setSelectedCommentText(selText);
241
						}
242
						IEditorInput input = editor.getEditorInput();
243
						if (input instanceof RepositoryTaskEditorInput) {
244
							RepositoryTaskEditorInput repositoryInput = (RepositoryTaskEditorInput) input;
245
							newBugFromCommentAction.setTaskData(repositoryInput.getTaskData());
246
						}
247
						manager.add(newBugFromCommentAction);
248
					}
249
				}
250
			}
223
			
251
			
224
			if (task.isActive()) {
252
			if (task.isActive()) {
225
				manager.add(new TaskDeactivateAction() {
253
				manager.add(new TaskDeactivateAction() {
(-)src/org/eclipse/mylyn/internal/tasks/ui/actions/NewBugFromCommentAction.java (+122 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
	protected String selectedCommentText;
47
48
	public NewBugFromCommentAction() {
49
		super(LABEL);
50
		setId(ID);
51
		setImageDescriptor(TasksUiImages.TASK_NEW);
52
53
		setAccelerator(SWT.MOD1 + SWT.MOD2 + 'n');
54
	}
55
56
	public void run(IAction action) {
57
		run();
58
	}
59
60
	@Override
61
	public void run() {
62
		NewTaskWizard wizard = new NewTaskWizard();
63
		Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
64
		if (shell != null && !shell.isDisposed()) {
65
			WizardDialog dialog = new WizardDialog(shell, wizard);
66
			dialog.setBlockOnOpen(true);
67
			if (dialog.open() == WizardDialog.CANCEL) {
68
				return;
69
			}
70
71
			IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
72
			AbstractRepositoryTaskEditor editor = null;
73
			String summary = "";
74
75
			AbstractRepositoryConnector connector = null;
76
			TaskRepositoryManager repositoryManager = TasksUiPlugin.getRepositoryManager();
77
			connector = repositoryManager.getRepositoryConnector(taskData.getRepositoryKind());
78
			String textToInsert ;
79
			if (selectedCommentText != null && !selectedCommentText.equals("")) {
80
				textToInsert = selectedCommentText;
81
			} else {
82
				textToInsert = taskComment.getText();
83
			}
84
			String description = "From task: " + connector.getTaskUrl(taskData.getRepositoryUrl(), taskData.getId())
85
					+ " comment#" + taskComment.getNumber() + "\n\nselected original-comment:\n" + textToInsert;
86
87
			try {
88
				TaskEditor taskEditor = (TaskEditor) page.getActiveEditor();
89
				editor = (AbstractRepositoryTaskEditor) taskEditor.getActivePageInstance();
90
			} catch (ClassCastException err) {
91
				Clipboard clipboard = new Clipboard(page.getWorkbenchWindow().getShell().getDisplay());
92
				clipboard.setContents(new Object[] { summary + "\n" + description },
93
						new Transfer[] { TextTransfer.getInstance() });
94
95
				MessageDialog.openInformation(
96
						page.getWorkbenchWindow().getShell(),
97
						ITasksUiConstants.TITLE_DIALOG,
98
						"This connector does not provide a rich task editor for creating tasks.\n\n"
99
								+ "The error contents have been placed in the clipboard so that you can paste them into the entry form.");
100
				return;
101
			}
102
103
			summary = taskData.getSummary();
104
			editor.setSummaryText(summary);
105
			editor.setDescriptionText(description);
106
107
		}
108
	}
109
110
	public void setTaskComment(TaskComment taskComment) {
111
		this.taskComment = taskComment;
112
	}
113
114
	public void setTaskData(RepositoryTaskData taskData) {
115
		this.taskData = taskData;
116
	}
117
118
	public void setSelectedCommentText(String selectedCommentText) {
119
		this.selectedCommentText = selectedCommentText;
120
	}
121
122
}

Return to bug 169426