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 / +4 lines)
Lines 30-35 Link Here
30
import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
30
import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
31
import org.eclipse.mylyn.internal.bugzilla.ui.BugzillaImages;
31
import org.eclipse.mylyn.internal.bugzilla.ui.BugzillaImages;
32
import org.eclipse.mylyn.internal.bugzilla.ui.TaskAttachmentHyperlink;
32
import org.eclipse.mylyn.internal.bugzilla.ui.TaskAttachmentHyperlink;
33
import org.eclipse.mylyn.internal.bugzilla.ui.TaskAttachmentTableEditorHyperlink;
33
import org.eclipse.mylyn.internal.bugzilla.ui.search.BugzillaSearchPage;
34
import org.eclipse.mylyn.internal.bugzilla.ui.search.BugzillaSearchPage;
34
import org.eclipse.mylyn.internal.bugzilla.ui.wizard.NewBugzillaTaskWizard;
35
import org.eclipse.mylyn.internal.bugzilla.ui.wizard.NewBugzillaTaskWizard;
35
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
36
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
Lines 220-230 Link Here
220
			if (index == -1 || (index >= ma.start() && index <= ma.end())) {
221
			if (index == -1 || (index >= ma.start() && index <= ma.end())) {
221
				// attachment
222
				// attachment
222
				Region region = new Region(textOffset + ma.start(), ma.end() - ma.start());
223
				Region region = new Region(textOffset + ma.start(), ma.end() - ma.start());
223
				TaskAttachmentHyperlink link = new TaskAttachmentHyperlink(region, repository, ma.group(1));
224
				TaskAttachmentHyperlink link0 = new TaskAttachmentHyperlink(region, repository, ma.group(1));
224
				if (hyperlinksFound == null) {
225
				if (hyperlinksFound == null) {
225
					hyperlinksFound = new ArrayList<IHyperlink>();
226
					hyperlinksFound = new ArrayList<IHyperlink>();
226
				}
227
				}
227
				hyperlinksFound.add(link);
228
				hyperlinksFound.add(link0);
229
				hyperlinksFound.add(new TaskAttachmentTableEditorHyperlink(region, repository, ma.group(1)));
228
			}
230
			}
229
		}
231
		}
230
232
(-)src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorAttachmentPart.java (-1 / +49 lines)
Lines 32-37 Link Here
32
import org.eclipse.jface.viewers.StructuredSelection;
32
import org.eclipse.jface.viewers.StructuredSelection;
33
import org.eclipse.jface.viewers.TableViewer;
33
import org.eclipse.jface.viewers.TableViewer;
34
import org.eclipse.jface.window.ToolTip;
34
import org.eclipse.jface.window.ToolTip;
35
import org.eclipse.mylyn.internal.provisional.commons.ui.CommonFormUtil;
35
import org.eclipse.mylyn.internal.provisional.commons.ui.CommonImages;
36
import org.eclipse.mylyn.internal.provisional.commons.ui.CommonImages;
36
import org.eclipse.mylyn.internal.provisional.commons.ui.TableSorter;
37
import org.eclipse.mylyn.internal.provisional.commons.ui.TableSorter;
37
import org.eclipse.mylyn.internal.provisional.commons.ui.TableViewerSupport;
38
import org.eclipse.mylyn.internal.provisional.commons.ui.TableViewerSupport;
Lines 55-64 Link Here
55
import org.eclipse.swt.widgets.Menu;
56
import org.eclipse.swt.widgets.Menu;
56
import org.eclipse.swt.widgets.Table;
57
import org.eclipse.swt.widgets.Table;
57
import org.eclipse.swt.widgets.TableColumn;
58
import org.eclipse.swt.widgets.TableColumn;
59
import org.eclipse.swt.widgets.TableItem;
58
import org.eclipse.ui.IWorkbenchPage;
60
import org.eclipse.ui.IWorkbenchPage;
61
import org.eclipse.ui.forms.IManagedForm;
59
import org.eclipse.ui.forms.events.ExpansionAdapter;
62
import org.eclipse.ui.forms.events.ExpansionAdapter;
60
import org.eclipse.ui.forms.events.ExpansionEvent;
63
import org.eclipse.ui.forms.events.ExpansionEvent;
64
import org.eclipse.ui.forms.widgets.ExpandableComposite;
61
import org.eclipse.ui.forms.widgets.FormToolkit;
65
import org.eclipse.ui.forms.widgets.FormToolkit;
66
import org.eclipse.ui.forms.widgets.ScrolledForm;
62
import org.eclipse.ui.forms.widgets.Section;
67
import org.eclipse.ui.forms.widgets.Section;
63
68
64
/**
69
/**
Lines 116-127 Link Here
116
121
117
	private Composite attachmentsComposite;
122
	private Composite attachmentsComposite;
118
123
124
	private Table attachmentsTable;
125
119
	public TaskEditorAttachmentPart() {
126
	public TaskEditorAttachmentPart() {
120
		setPartName(Messages.TaskEditorAttachmentPart_Attachments);
127
		setPartName(Messages.TaskEditorAttachmentPart_Attachments);
121
	}
128
	}
122
129
123
	private void createAttachmentTable(FormToolkit toolkit, final Composite attachmentsComposite) {
130
	private void createAttachmentTable(FormToolkit toolkit, final Composite attachmentsComposite) {
124
		Table attachmentsTable = toolkit.createTable(attachmentsComposite, SWT.MULTI | SWT.FULL_SELECTION);
131
		attachmentsTable = toolkit.createTable(attachmentsComposite, SWT.MULTI | SWT.FULL_SELECTION);
125
		attachmentsTable.setLinesVisible(true);
132
		attachmentsTable.setLinesVisible(true);
126
		attachmentsTable.setHeaderVisible(true);
133
		attachmentsTable.setHeaderVisible(true);
127
		attachmentsTable.setLayout(new GridLayout());
134
		attachmentsTable.setLayout(new GridLayout());
Lines 311-314 Link Here
311
318
312
		OpenTaskAttachmentHandler.openAttachments(page, attachments);
319
		OpenTaskAttachmentHandler.openAttachments(page, attachments);
313
	}
320
	}
321
322
	@Override
323
	public boolean setFormInput(Object input) {
324
		if (input instanceof String) {
325
			String text = (String) input;
326
			if (attachments != null) {
327
				for (TaskAttribute attachmentAttribute : attachments) {
328
					if (text.equals(attachmentAttribute.getId())) {
329
						CommonFormUtil.setExpanded((ExpandableComposite) getControl(), true);
330
331
						return selectReveal(attachmentAttribute);
332
					}
333
				}
334
			}
335
		}
336
		return super.setFormInput(input);
337
	}
338
339
	public boolean selectReveal(TaskAttribute attachmentAttribute) {
340
		if (attachmentAttribute == null || attachmentsTable == null) {
341
			return false;
342
		}
343
		TableItem[] attachments = attachmentsTable.getItems();
344
		int index = 0;
345
		for (TableItem attachment : attachments) {
346
			Object data = attachment.getData();
347
			if (data instanceof ITaskAttachment) {
348
				ITaskAttachment attachmentData = ((ITaskAttachment) data);
349
				if (attachmentData.getTaskAttribute().getValue().equals(attachmentAttribute.getValue())) {
350
					attachmentsTable.deselectAll();
351
					attachmentsTable.select(index);
352
					IManagedForm mform = getManagedForm();
353
					ScrolledForm form = mform.getForm();
354
					EditorUtil.focusOn(form, attachmentsTable);
355
					return true;
356
				}
357
			}
358
			index++;
359
		}
360
		return false;
361
	}
314
}
362
}

Return to bug 199283