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 199283 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/mylyn/internal/bugzilla/ui/Messages.java (-1 / +3 lines)
Lines 16-22 Link Here
16
public class Messages extends NLS {
16
public class Messages extends NLS {
17
	private static final String BUNDLE_NAME = "org.eclipse.mylyn.internal.bugzilla.ui.messages"; //$NON-NLS-1$
17
	private static final String BUNDLE_NAME = "org.eclipse.mylyn.internal.bugzilla.ui.messages"; //$NON-NLS-1$
18
18
19
	public static String TaskAttachmentHyperlink_Open_Attachment_X_in_X;
19
	public static String TaskAttachmentHyperlink_Open_Attachment_X_in_Y;
20
21
	public static String TaskAttachmentTableEditorHyperlink_Show_Attachment_X_in_Y;
20
22
21
	static {
23
	static {
22
		// initialize resource bundle
24
		// initialize resource bundle
(-)src/org/eclipse/mylyn/internal/bugzilla/ui/TaskAttachmentHyperlink.java (-1 / +1 lines)
Lines 43-49 Link Here
43
	}
43
	}
44
44
45
	public String getHyperlinkText() {
45
	public String getHyperlinkText() {
46
		return MessageFormat.format(Messages.TaskAttachmentHyperlink_Open_Attachment_X_in_X, attachmentId,
46
		return MessageFormat.format(Messages.TaskAttachmentHyperlink_Open_Attachment_X_in_Y, attachmentId,
47
				repository.getRepositoryLabel());
47
				repository.getRepositoryLabel());
48
	}
48
	}
49
49
(-)src/org/eclipse/mylyn/internal/bugzilla/ui/TaskAttachmentTableEditorHyperlink.java (+140 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 Frank Becker 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
 * Contributors:
9
 *     Frank Becker - initial API and implementation
10
 *******************************************************************************/
11
12
package org.eclipse.mylyn.internal.bugzilla.ui;
13
14
import java.text.MessageFormat;
15
16
import org.eclipse.core.runtime.Assert;
17
import org.eclipse.jface.text.IRegion;
18
import org.eclipse.jface.text.hyperlink.IHyperlink;
19
import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
20
import org.eclipse.mylyn.tasks.core.TaskRepository;
21
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
22
import org.eclipse.mylyn.tasks.ui.TasksUiUtil;
23
import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorPage;
24
import org.eclipse.mylyn.tasks.ui.editors.TaskEditor;
25
import org.eclipse.ui.IEditorPart;
26
import org.eclipse.ui.IWorkbenchPage;
27
import org.eclipse.ui.PlatformUI;
28
import org.eclipse.ui.forms.editor.IFormPage;
29
30
/**
31
 * @since 3.2
32
 */
33
public final class TaskAttachmentTableEditorHyperlink implements IHyperlink {
34
35
	private final IRegion region;
36
37
	private final TaskRepository repository;
38
39
	private final String attachmentId;
40
41
	public TaskAttachmentTableEditorHyperlink(IRegion region, TaskRepository repository, String attachmentId) {
42
		Assert.isNotNull(repository);
43
		this.region = region;
44
		this.repository = repository;
45
		this.attachmentId = attachmentId;
46
	}
47
48
	public IRegion getHyperlinkRegion() {
49
		return region;
50
	}
51
52
	public String getHyperlinkText() {
53
		return MessageFormat.format(Messages.TaskAttachmentTableEditorHyperlink_Show_Attachment_X_in_Y, attachmentId,
54
				repository.getRepositoryLabel());
55
	}
56
57
	public String getTypeLabel() {
58
		return null;
59
	}
60
61
	public void open() {
62
		AbstractTaskEditorPage page = getTaskEditorPage();
63
		if (page != null) {
64
			if (!page.selectReveal(TaskAttribute.PREFIX_ATTACHMENT + attachmentId)) {
65
				String url = repository.getUrl() + IBugzillaConstants.URL_GET_ATTACHMENT_SUFFIX + attachmentId;
66
				TasksUiUtil.openUrl(url);
67
			}
68
		}
69
	}
70
71
	@Override
72
	public int hashCode() {
73
		final int prime = 31;
74
		int result = 1;
75
		result = prime * result + ((attachmentId == null) ? 0 : attachmentId.hashCode());
76
		result = prime * result + ((region == null) ? 0 : region.hashCode());
77
		result = prime * result + ((repository == null) ? 0 : repository.hashCode());
78
		return result;
79
	}
80
81
	@Override
82
	public boolean equals(Object obj) {
83
		if (this == obj) {
84
			return true;
85
		}
86
		if (obj == null) {
87
			return false;
88
		}
89
		if (getClass() != obj.getClass()) {
90
			return false;
91
		}
92
		TaskAttachmentTableEditorHyperlink other = (TaskAttachmentTableEditorHyperlink) obj;
93
		if (attachmentId == null) {
94
			if (other.attachmentId != null) {
95
				return false;
96
			}
97
		} else if (!attachmentId.equals(other.attachmentId)) {
98
			return false;
99
		}
100
		if (region == null) {
101
			if (other.region != null) {
102
				return false;
103
			}
104
		} else if (!region.equals(other.region)) {
105
			return false;
106
		}
107
		if (repository == null) {
108
			if (other.repository != null) {
109
				return false;
110
			}
111
		} else if (!repository.equals(other.repository)) {
112
			return false;
113
		}
114
		return true;
115
	}
116
117
	@Override
118
	public String toString() {
119
		return "TaskAttachmentHyperlink [attachmentId=" + attachmentId + ", region=" + region + ", repository=" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
120
				+ repository + "]"; //$NON-NLS-1$
121
	}
122
123
	protected AbstractTaskEditorPage getTaskEditorPage() {
124
		IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
125
		if (activePage == null) {
126
			return null;
127
		}
128
		IEditorPart editorPart = activePage.getActiveEditor();
129
		AbstractTaskEditorPage taskEditorPage = null;
130
		if (editorPart instanceof TaskEditor) {
131
			TaskEditor taskEditor = (TaskEditor) editorPart;
132
			IFormPage formPage = taskEditor.getActivePageInstance();
133
			if (formPage instanceof AbstractTaskEditorPage) {
134
				taskEditorPage = (AbstractTaskEditorPage) formPage;
135
			}
136
		}
137
		return taskEditorPage;
138
	}
139
140
}
(-)src/org/eclipse/mylyn/internal/bugzilla/ui/messages.properties (-1 / +2 lines)
Lines 8-11 Link Here
8
# Contributors:
8
# Contributors:
9
#     Tasktop Technologies - initial API and implementation
9
#     Tasktop Technologies - initial API and implementation
10
###############################################################################
10
###############################################################################
11
TaskAttachmentHyperlink_Open_Attachment_X_in_X=Open Attachment {0} in {1}
11
TaskAttachmentHyperlink_Open_Attachment_X_in_Y=Open Attachment {0} in {1}
12
TaskAttachmentTableEditorHyperlink_Show_Attachment_X_in_Y=Show Attachment {0} in {1}
(-)src/org/eclipse/mylyn/internal/bugzilla/ui/tasklist/BugzillaConnectorUi.java (-2 / +25 lines)
Lines 19-24 Link Here
19
import java.util.regex.Matcher;
19
import java.util.regex.Matcher;
20
import java.util.regex.Pattern;
20
import java.util.regex.Pattern;
21
21
22
import org.eclipse.core.runtime.Platform;
22
import org.eclipse.jface.resource.ImageDescriptor;
23
import org.eclipse.jface.resource.ImageDescriptor;
23
import org.eclipse.jface.text.Region;
24
import org.eclipse.jface.text.Region;
24
import org.eclipse.jface.text.hyperlink.IHyperlink;
25
import org.eclipse.jface.text.hyperlink.IHyperlink;
Lines 30-35 Link Here
30
import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
31
import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
31
import org.eclipse.mylyn.internal.bugzilla.ui.BugzillaImages;
32
import org.eclipse.mylyn.internal.bugzilla.ui.BugzillaImages;
32
import org.eclipse.mylyn.internal.bugzilla.ui.TaskAttachmentHyperlink;
33
import org.eclipse.mylyn.internal.bugzilla.ui.TaskAttachmentHyperlink;
34
import org.eclipse.mylyn.internal.bugzilla.ui.TaskAttachmentTableEditorHyperlink;
33
import org.eclipse.mylyn.internal.bugzilla.ui.search.BugzillaSearchPage;
35
import org.eclipse.mylyn.internal.bugzilla.ui.search.BugzillaSearchPage;
34
import org.eclipse.mylyn.internal.bugzilla.ui.wizard.NewBugzillaTaskWizard;
36
import org.eclipse.mylyn.internal.bugzilla.ui.wizard.NewBugzillaTaskWizard;
35
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
37
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
Lines 45-50 Link Here
45
import org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositoryQueryPage;
47
import org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositoryQueryPage;
46
import org.eclipse.mylyn.tasks.ui.wizards.ITaskRepositoryPage;
48
import org.eclipse.mylyn.tasks.ui.wizards.ITaskRepositoryPage;
47
import org.eclipse.mylyn.tasks.ui.wizards.RepositoryQueryWizard;
49
import org.eclipse.mylyn.tasks.ui.wizards.RepositoryQueryWizard;
50
import org.osgi.framework.Bundle;
51
import org.osgi.framework.Version;
48
52
49
/**
53
/**
50
 * @author Mik Kersten
54
 * @author Mik Kersten
Lines 65-70 Link Here
65
69
66
	private static final Pattern PATTERN_ATTACHMENT = Pattern.compile(REGEXP_ATTACHMENT, Pattern.CASE_INSENSITIVE);
70
	private static final Pattern PATTERN_ATTACHMENT = Pattern.compile(REGEXP_ATTACHMENT, Pattern.CASE_INSENSITIVE);
67
71
72
	/*
73
	 * because of bug# 322293 (NPE when select Hyperlink from MultipleHyperlinkPresenter List)
74
	 * for MacOS we enable this only if running on Eclipse >= "3.7.0.v201101192000"
75
	 * 
76
	 */
77
	private final boolean doAttachmentTableEditorHyperlink;
78
79
	public BugzillaConnectorUi() {
80
		super();
81
		Bundle bundle = Platform.getBundle("org.eclipse.platform"); //$NON-NLS-1$
82
		String versionString = bundle.getHeaders().get("Bundle-Version"); //$NON-NLS-1$
83
84
		Version version = new Version(versionString);
85
		doAttachmentTableEditorHyperlink = version.compareTo(new Version("3.7.0.v201101192000")) >= 0; //$NON-NLS-1$
86
	}
87
68
	@Override
88
	@Override
69
	public String getAccountCreationUrl(TaskRepository taskRepository) {
89
	public String getAccountCreationUrl(TaskRepository taskRepository) {
70
		return taskRepository.getRepositoryUrl() + "/createaccount.cgi"; //$NON-NLS-1$
90
		return taskRepository.getRepositoryUrl() + "/createaccount.cgi"; //$NON-NLS-1$
Lines 220-230 Link Here
220
			if (index == -1 || (index >= ma.start() && index <= ma.end())) {
240
			if (index == -1 || (index >= ma.start() && index <= ma.end())) {
221
				// attachment
241
				// attachment
222
				Region region = new Region(textOffset + ma.start(), ma.end() - ma.start());
242
				Region region = new Region(textOffset + ma.start(), ma.end() - ma.start());
223
				TaskAttachmentHyperlink link = new TaskAttachmentHyperlink(region, repository, ma.group(1));
243
				TaskAttachmentHyperlink link0 = new TaskAttachmentHyperlink(region, repository, ma.group(1));
224
				if (hyperlinksFound == null) {
244
				if (hyperlinksFound == null) {
225
					hyperlinksFound = new ArrayList<IHyperlink>();
245
					hyperlinksFound = new ArrayList<IHyperlink>();
226
				}
246
				}
227
				hyperlinksFound.add(link);
247
				hyperlinksFound.add(link0);
248
				if (doAttachmentTableEditorHyperlink) {
249
					hyperlinksFound.add(new TaskAttachmentTableEditorHyperlink(region, repository, ma.group(1)));
250
				}
228
			}
251
			}
229
		}
252
		}
230
253
(-)src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorAttachmentPart.java (+49 lines)
Lines 33-38 Link Here
33
import org.eclipse.jface.viewers.StructuredSelection;
33
import org.eclipse.jface.viewers.StructuredSelection;
34
import org.eclipse.jface.viewers.TableViewer;
34
import org.eclipse.jface.viewers.TableViewer;
35
import org.eclipse.jface.window.ToolTip;
35
import org.eclipse.jface.window.ToolTip;
36
import org.eclipse.mylyn.internal.provisional.commons.ui.CommonFormUtil;
36
import org.eclipse.mylyn.internal.provisional.commons.ui.CommonImages;
37
import org.eclipse.mylyn.internal.provisional.commons.ui.CommonImages;
37
import org.eclipse.mylyn.internal.provisional.commons.ui.TableSorter;
38
import org.eclipse.mylyn.internal.provisional.commons.ui.TableSorter;
38
import org.eclipse.mylyn.internal.provisional.commons.ui.TableViewerSupport;
39
import org.eclipse.mylyn.internal.provisional.commons.ui.TableViewerSupport;
Lines 56-65 Link Here
56
import org.eclipse.swt.widgets.Menu;
57
import org.eclipse.swt.widgets.Menu;
57
import org.eclipse.swt.widgets.Table;
58
import org.eclipse.swt.widgets.Table;
58
import org.eclipse.swt.widgets.TableColumn;
59
import org.eclipse.swt.widgets.TableColumn;
60
import org.eclipse.swt.widgets.TableItem;
59
import org.eclipse.ui.IWorkbenchPage;
61
import org.eclipse.ui.IWorkbenchPage;
62
import org.eclipse.ui.forms.IManagedForm;
60
import org.eclipse.ui.forms.events.ExpansionAdapter;
63
import org.eclipse.ui.forms.events.ExpansionAdapter;
61
import org.eclipse.ui.forms.events.ExpansionEvent;
64
import org.eclipse.ui.forms.events.ExpansionEvent;
65
import org.eclipse.ui.forms.widgets.ExpandableComposite;
62
import org.eclipse.ui.forms.widgets.FormToolkit;
66
import org.eclipse.ui.forms.widgets.FormToolkit;
67
import org.eclipse.ui.forms.widgets.ScrolledForm;
63
import org.eclipse.ui.forms.widgets.Section;
68
import org.eclipse.ui.forms.widgets.Section;
64
69
65
/**
70
/**
Lines 117-122 Link Here
117
122
118
	private Composite attachmentsComposite;
123
	private Composite attachmentsComposite;
119
124
125
	private Table attachmentsTable;
126
120
	public TaskEditorAttachmentPart() {
127
	public TaskEditorAttachmentPart() {
121
		setPartName(Messages.TaskEditorAttachmentPart_Attachments);
128
		setPartName(Messages.TaskEditorAttachmentPart_Attachments);
122
	}
129
	}
Lines 315-318 Link Here
315
			// canceled
322
			// canceled
316
		}
323
		}
317
	}
324
	}
325
326
	@Override
327
	public boolean setFormInput(Object input) {
328
		if (input instanceof String) {
329
			String text = (String) input;
330
			if (attachments != null) {
331
				for (TaskAttribute attachmentAttribute : attachments) {
332
					if (text.equals(attachmentAttribute.getId())) {
333
						CommonFormUtil.setExpanded((ExpandableComposite) getControl(), true);
334
335
						return selectReveal(attachmentAttribute);
336
					}
337
				}
338
			}
339
		}
340
		return super.setFormInput(input);
341
	}
342
343
	public boolean selectReveal(TaskAttribute attachmentAttribute) {
344
		if (attachmentAttribute == null || attachmentsTable == null) {
345
			return false;
346
		}
347
		TableItem[] attachments = attachmentsTable.getItems();
348
		int index = 0;
349
		for (TableItem attachment : attachments) {
350
			Object data = attachment.getData();
351
			if (data instanceof ITaskAttachment) {
352
				ITaskAttachment attachmentData = ((ITaskAttachment) data);
353
				if (attachmentData.getTaskAttribute().getValue().equals(attachmentAttribute.getValue())) {
354
					attachmentsTable.deselectAll();
355
					attachmentsTable.select(index);
356
					IManagedForm mform = getManagedForm();
357
					ScrolledForm form = mform.getForm();
358
					EditorUtil.focusOn(form, attachmentsTable);
359
					return true;
360
				}
361
			}
362
			index++;
363
		}
364
		return false;
365
	}
366
318
}
367
}
(-)src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorOutlineNode.java (+7 lines)
Lines 31-36 Link Here
31
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
31
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
32
import org.eclipse.mylyn.tasks.core.data.TaskData;
32
import org.eclipse.mylyn.tasks.core.data.TaskData;
33
import org.eclipse.mylyn.tasks.core.data.TaskRelation;
33
import org.eclipse.mylyn.tasks.core.data.TaskRelation;
34
import org.eclipse.mylyn.tasks.core.data.TaskRelation.Direction;
34
import org.eclipse.mylyn.tasks.ui.TasksUi;
35
import org.eclipse.mylyn.tasks.ui.TasksUi;
35
import org.eclipse.osgi.util.NLS;
36
import org.eclipse.osgi.util.NLS;
36
37
Lines 144-149 Link Here
144
						label = NLS.bind(Messages.TaskEditorOutlineNode_TaskRelation_Label,
145
						label = NLS.bind(Messages.TaskEditorOutlineNode_TaskRelation_Label,
145
								new Object[] { taskRelation.getTaskId(), Messages.TaskEditorOutlineNode_unknown_Label });
146
								new Object[] { taskRelation.getTaskId(), Messages.TaskEditorOutlineNode_unknown_Label });
146
					}
147
					}
148
149
					if (taskRelation.getDirection().compareTo(Direction.INWARD) == 0) {
150
						label = label + Messages.TaskEditorOutlineNode_ParentRelation;
151
					} else {
152
						label = label + Messages.TaskEditorOutlineNode_ChildRelation;
153
					}
147
					TaskEditorOutlineNode childNode = new TaskEditorOutlineNode(label);
154
					TaskEditorOutlineNode childNode = new TaskEditorOutlineNode(label);
148
155
149
					childNode.setTaskRelation(taskRelation);
156
					childNode.setTaskRelation(taskRelation);
(-)src/org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage.java (-1 / +40 lines)
Lines 1732-1738 Link Here
1732
1732
1733
	@Override
1733
	@Override
1734
	public boolean selectReveal(Object object) {
1734
	public boolean selectReveal(Object object) {
1735
		if (object instanceof TaskEditorOutlineNode) {
1735
		if (object instanceof String) {
1736
			String objString = (String) object;
1737
			if (objString != null && objString.startsWith(TaskAttribute.PREFIX_ATTACHMENT)) {
1738
				AbstractTaskEditorPart actionPart = this.getPart(AbstractTaskEditorPage.ID_PART_ATTACHMENTS);
1739
				if (actionPart != null && actionPart.getControl() instanceof ExpandableComposite) {
1740
					CommonFormUtil.setExpanded((ExpandableComposite) actionPart.getControl(), true);
1741
					if (actionPart.getControl() instanceof Section) {
1742
						Control client = actionPart.getControl();
1743
						if (client instanceof Composite) {
1744
							for (Control control : ((Composite) client).getChildren()) {
1745
								if (control instanceof Composite) {
1746
									for (Control control1 : ((Composite) control).getChildren()) {
1747
										if (control1 instanceof org.eclipse.swt.widgets.Table) {
1748
											org.eclipse.swt.widgets.Table attachmentTable = ((org.eclipse.swt.widgets.Table) control1);
1749
											TableItem[] attachments = attachmentTable.getItems();
1750
											int index = 0;
1751
											for (TableItem attachment : attachments) {
1752
												Object data = attachment.getData();
1753
												if (data instanceof ITaskAttachment) {
1754
													ITaskAttachment attachmentData = ((ITaskAttachment) data);
1755
													if (attachmentData.getTaskAttribute().getId().equals(objString)) {
1756
														attachmentTable.deselectAll();
1757
														attachmentTable.select(index);
1758
														IManagedForm mform = actionPart.getManagedForm();
1759
														ScrolledForm form = mform.getForm();
1760
														EditorUtil.focusOn(form, attachmentTable);
1761
														return true;
1762
													}
1763
												}
1764
												index++;
1765
											}
1766
										}
1767
									}
1768
								}
1769
							}
1770
						}
1771
					}
1772
				}
1773
			}
1774
		} else if (object instanceof TaskEditorOutlineNode) {
1736
			TaskEditorOutlineNode node = (TaskEditorOutlineNode) object;
1775
			TaskEditorOutlineNode node = (TaskEditorOutlineNode) object;
1737
			TaskAttribute attribute = node.getData();
1776
			TaskAttribute attribute = node.getData();
1738
			if (attribute != null) {
1777
			if (attribute != null) {

Return to bug 199283