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 (+4 lines)
Lines 18-23 Link Here
18
18
19
	public static String TaskAttachmentHyperlink_Open_Attachment_X_in_X;
19
	public static String TaskAttachmentHyperlink_Open_Attachment_X_in_X;
20
20
21
	public static String TaskAttachmentHyperlink_Open_With_Browser;
22
23
	public static String TaskAttachmentHyperlink_Show_in_Editor;
24
21
	static {
25
	static {
22
		// initialize resource bundle
26
		// initialize resource bundle
23
		NLS.initializeMessages(BUNDLE_NAME, Messages.class);
27
		NLS.initializeMessages(BUNDLE_NAME, Messages.class);
(-)src/org/eclipse/mylyn/internal/bugzilla/ui/TaskAttachmentHyperlink.java (-2 / +61 lines)
Lines 18-24 Link Here
18
import org.eclipse.jface.text.hyperlink.IHyperlink;
18
import org.eclipse.jface.text.hyperlink.IHyperlink;
19
import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
19
import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
20
import org.eclipse.mylyn.tasks.core.TaskRepository;
20
import org.eclipse.mylyn.tasks.core.TaskRepository;
21
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
21
import org.eclipse.mylyn.tasks.ui.TasksUiUtil;
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.swt.SWT;
26
import org.eclipse.swt.widgets.Display;
27
import org.eclipse.swt.widgets.Event;
28
import org.eclipse.swt.widgets.Listener;
29
import org.eclipse.swt.widgets.Menu;
30
import org.eclipse.swt.widgets.MenuItem;
31
import org.eclipse.ui.IEditorPart;
32
import org.eclipse.ui.IWorkbenchPage;
33
import org.eclipse.ui.PlatformUI;
34
import org.eclipse.ui.forms.editor.IFormPage;
22
35
23
/**
36
/**
24
 * @since 3.2
37
 * @since 3.2
Lines 52-59 Link Here
52
	}
65
	}
53
66
54
	public void open() {
67
	public void open() {
55
		String url = repository.getUrl() + IBugzillaConstants.URL_GET_ATTACHMENT_SUFFIX + attachmentId;
68
		Display display = PlatformUI.getWorkbench().getDisplay();
56
		TasksUiUtil.openUrl(url);
69
		Menu menu = new Menu(display.getActiveShell(), SWT.POP_UP);
70
		MenuItem item = new MenuItem(menu, SWT.PUSH);
71
		item.setText(Messages.TaskAttachmentHyperlink_Show_in_Editor);
72
		item.addListener(SWT.Selection, new Listener() {
73
			public void handleEvent(final Event event) {
74
				AbstractTaskEditorPage page = getTaskEditorPage();
75
				if (page != null) {
76
					if (!page.selectReveal(TaskAttribute.PREFIX_ATTACHMENT + attachmentId)) {
77
						String url = repository.getUrl() + IBugzillaConstants.URL_GET_ATTACHMENT_SUFFIX + attachmentId;
78
						TasksUiUtil.openUrl(url);
79
					}
80
				}
81
			}
82
		});
83
		item = new MenuItem(menu, SWT.PUSH);
84
		item.setText(Messages.TaskAttachmentHyperlink_Open_With_Browser);
85
		item.addListener(SWT.Selection, new Listener() {
86
			public void handleEvent(final Event event) {
87
				String url = repository.getUrl() + IBugzillaConstants.URL_GET_ATTACHMENT_SUFFIX + attachmentId;
88
				TasksUiUtil.openUrl(url);
89
			}
90
		});
91
92
		menu.setVisible(true);
93
		while (!menu.isDisposed() && menu.isVisible()) {
94
			if (!display.readAndDispatch()) {
95
				display.sleep();
96
			}
97
		}
98
		menu.dispose();
57
	}
99
	}
58
100
59
	@Override
101
	@Override
Lines 108-111 Link Here
108
				+ repository + "]"; //$NON-NLS-1$
150
				+ repository + "]"; //$NON-NLS-1$
109
	}
151
	}
110
152
153
	protected AbstractTaskEditorPage getTaskEditorPage() {
154
		IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
155
		if (activePage == null) {
156
			return null;
157
		}
158
		IEditorPart editorPart = activePage.getActiveEditor();
159
		AbstractTaskEditorPage taskEditorPage = null;
160
		if (editorPart instanceof TaskEditor) {
161
			TaskEditor taskEditor = (TaskEditor) editorPart;
162
			IFormPage formPage = taskEditor.getActivePageInstance();
163
			if (formPage instanceof AbstractTaskEditorPage) {
164
				taskEditorPage = (AbstractTaskEditorPage) formPage;
165
			}
166
		}
167
		return taskEditorPage;
168
	}
169
111
}
170
}
(-)src/org/eclipse/mylyn/internal/bugzilla/ui/messages.properties (-1 / +3 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_X=Open Attachment {0} in {1}
12
TaskAttachmentHyperlink_Open_With_Browser=Open with Browser
13
TaskAttachmentHyperlink_Show_in_Editor=Show in Editor
(-)src/org/eclipse/mylyn/internal/tasks/ui/editors/EditorUtil.java (-3 / +5 lines)
Lines 148-157 Link Here
148
	}
148
	}
149
149
150
	/**
150
	/**
151
	 * Scroll to a specified piece of text
151
	 * Scroll to a specified control
152
	 * 
152
	 * 
153
	 * @param form
154
	 *            The ScrolledForm we want to set the new Origin
153
	 * @param control
155
	 * @param control
154
	 *            The StyledText to scroll to
156
	 *            Control that should be visible
155
	 */
157
	 */
156
	public static void focusOn(ScrolledForm form, Control control) {
158
	public static void focusOn(ScrolledForm form, Control control) {
157
		int pos = 0;
159
		int pos = 0;
Lines 163-169 Link Here
163
			control = control.getParent();
165
			control = control.getParent();
164
		}
166
		}
165
167
166
		pos = pos - 60; // form.getOrigin().y;
168
		pos = pos - 60;
167
		if (!form.getBody().isDisposed()) {
169
		if (!form.getBody().isDisposed()) {
168
			form.setOrigin(0, pos);
170
			form.setOrigin(0, pos);
169
		}
171
		}
(-)src/org/eclipse/mylyn/internal/tasks/ui/editors/TaskEditorAttachmentPart.java (-3 / +54 lines)
Lines 32-37 Link Here
32
import org.eclipse.jface.viewers.Viewer;
32
import org.eclipse.jface.viewers.Viewer;
33
import org.eclipse.jface.viewers.ViewerSorter;
33
import org.eclipse.jface.viewers.ViewerSorter;
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.tasks.core.TaskAttachment;
37
import org.eclipse.mylyn.internal.tasks.core.TaskAttachment;
37
import org.eclipse.mylyn.internal.tasks.ui.commands.OpenTaskAttachmentHandler;
38
import org.eclipse.mylyn.internal.tasks.ui.commands.OpenTaskAttachmentHandler;
Lines 51-60 Link Here
51
import org.eclipse.swt.widgets.Menu;
52
import org.eclipse.swt.widgets.Menu;
52
import org.eclipse.swt.widgets.Table;
53
import org.eclipse.swt.widgets.Table;
53
import org.eclipse.swt.widgets.TableColumn;
54
import org.eclipse.swt.widgets.TableColumn;
55
import org.eclipse.swt.widgets.TableItem;
54
import org.eclipse.ui.IWorkbenchPage;
56
import org.eclipse.ui.IWorkbenchPage;
57
import org.eclipse.ui.forms.IManagedForm;
55
import org.eclipse.ui.forms.events.ExpansionAdapter;
58
import org.eclipse.ui.forms.events.ExpansionAdapter;
56
import org.eclipse.ui.forms.events.ExpansionEvent;
59
import org.eclipse.ui.forms.events.ExpansionEvent;
60
import org.eclipse.ui.forms.widgets.ExpandableComposite;
57
import org.eclipse.ui.forms.widgets.FormToolkit;
61
import org.eclipse.ui.forms.widgets.FormToolkit;
62
import org.eclipse.ui.forms.widgets.ScrolledForm;
58
import org.eclipse.ui.forms.widgets.Section;
63
import org.eclipse.ui.forms.widgets.Section;
59
64
60
/**
65
/**
Lines 80-96 Link Here
80
85
81
	private Composite attachmentsComposite;
86
	private Composite attachmentsComposite;
82
87
88
	private Table attachmentsTable;
89
83
	public TaskEditorAttachmentPart() {
90
	public TaskEditorAttachmentPart() {
84
		setPartName(Messages.TaskEditorAttachmentPart_Attachments);
91
		setPartName(Messages.TaskEditorAttachmentPart_Attachments);
85
	}
92
	}
86
93
87
	private void createAttachmentTable(FormToolkit toolkit, final Composite attachmentsComposite) {
94
	private void createAttachmentTable(FormToolkit toolkit, final Composite attachmentsComposite) {
88
		Table attachmentsTable = toolkit.createTable(attachmentsComposite, SWT.MULTI | SWT.FULL_SELECTION);
95
		attachmentsTable = toolkit.createTable(attachmentsComposite, SWT.MULTI | SWT.FULL_SELECTION);
89
		attachmentsTable.setLinesVisible(true);
96
		attachmentsTable.setLinesVisible(true);
90
		attachmentsTable.setHeaderVisible(true);
97
		attachmentsTable.setHeaderVisible(true);
91
		attachmentsTable.setLayout(new GridLayout());
98
		attachmentsTable.setLayout(new GridLayout());
92
		GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, false).hint(500, SWT.DEFAULT).applyTo(
99
		GridDataFactory.fillDefaults()
93
				attachmentsTable);
100
				.align(SWT.FILL, SWT.FILL)
101
				.grab(true, false)
102
				.hint(500, SWT.DEFAULT)
103
				.applyTo(attachmentsTable);
94
		attachmentsTable.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TREE_BORDER);
104
		attachmentsTable.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TREE_BORDER);
95
105
96
		for (int i = 0; i < attachmentsColumns.length; i++) {
106
		for (int i = 0; i < attachmentsColumns.length; i++) {
Lines 277-280 Link Here
277
287
278
		OpenTaskAttachmentHandler.openAttachments(page, attachments);
288
		OpenTaskAttachmentHandler.openAttachments(page, attachments);
279
	}
289
	}
290
291
	@Override
292
	public boolean setFormInput(Object input) {
293
		if (input instanceof String) {
294
			String text = (String) input;
295
			if (attachments != null) {
296
				for (TaskAttribute attachmentAttribute : attachments) {
297
					if (text.equals(attachmentAttribute.getId())) {
298
						CommonFormUtil.setExpanded((ExpandableComposite) getControl(), true);
299
300
						return selectReveal(attachmentAttribute);
301
					}
302
				}
303
			}
304
		}
305
		return super.setFormInput(input);
306
	}
307
308
	public boolean selectReveal(TaskAttribute attachmentAttribute) {
309
		if (attachmentAttribute == null || attachmentsTable == null) {
310
			return false;
311
		}
312
		TableItem[] attachments = attachmentsTable.getItems();
313
		int index = 0;
314
		for (TableItem attachment : attachments) {
315
			Object data = attachment.getData();
316
			if (data instanceof ITaskAttachment) {
317
				ITaskAttachment attachmentData = ((ITaskAttachment) data);
318
				if (attachmentData.getTaskAttribute().getValue().equals(attachmentAttribute.getValue())) {
319
					attachmentsTable.deselectAll();
320
					attachmentsTable.select(index);
321
					IManagedForm mform = getManagedForm();
322
					ScrolledForm form = mform.getForm();
323
					EditorUtil.focusOn(form, attachmentsTable);
324
					return true;
325
				}
326
			}
327
			index++;
328
		}
329
		return false;
330
	}
280
}
331
}
(-)src/org/eclipse/mylyn/tasks/ui/editors/AbstractTaskEditorPage.java (-7 / +13 lines)
Lines 92-101 Link Here
92
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
92
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
93
import org.eclipse.mylyn.tasks.core.IRepositoryElement;
93
import org.eclipse.mylyn.tasks.core.IRepositoryElement;
94
import org.eclipse.mylyn.tasks.core.ITask;
94
import org.eclipse.mylyn.tasks.core.ITask;
95
import org.eclipse.mylyn.tasks.core.ITask.SynchronizationState;
95
import org.eclipse.mylyn.tasks.core.ITaskAttachment;
96
import org.eclipse.mylyn.tasks.core.ITaskAttachment;
96
import org.eclipse.mylyn.tasks.core.RepositoryStatus;
97
import org.eclipse.mylyn.tasks.core.RepositoryStatus;
97
import org.eclipse.mylyn.tasks.core.TaskRepository;
98
import org.eclipse.mylyn.tasks.core.TaskRepository;
98
import org.eclipse.mylyn.tasks.core.ITask.SynchronizationState;
99
import org.eclipse.mylyn.tasks.core.data.ITaskDataWorkingCopy;
99
import org.eclipse.mylyn.tasks.core.data.ITaskDataWorkingCopy;
100
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
100
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
101
import org.eclipse.mylyn.tasks.core.data.TaskData;
101
import org.eclipse.mylyn.tasks.core.data.TaskData;
Lines 1291-1305 Link Here
1291
			if (part.getControl() != null) {
1291
			if (part.getControl() != null) {
1292
				if (ID_PART_ACTIONS.equals(part.getPartId())) {
1292
				if (ID_PART_ACTIONS.equals(part.getPartId())) {
1293
					// do not expand horizontally
1293
					// do not expand horizontally
1294
					GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(false, false).applyTo(
1294
					GridDataFactory.fillDefaults()
1295
							part.getControl());
1295
							.align(SWT.FILL, SWT.FILL)
1296
							.grab(false, false)
1297
							.applyTo(part.getControl());
1296
				} else {
1298
				} else {
1297
					if (part.getExpandVertically()) {
1299
					if (part.getExpandVertically()) {
1298
						GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(
1300
						GridDataFactory.fillDefaults()
1299
								part.getControl());
1301
								.align(SWT.FILL, SWT.FILL)
1302
								.grab(true, true)
1303
								.applyTo(part.getControl());
1300
					} else {
1304
					} else {
1301
						GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).grab(true, false).applyTo(
1305
						GridDataFactory.fillDefaults()
1302
								part.getControl());
1306
								.align(SWT.FILL, SWT.TOP)
1307
								.grab(true, false)
1308
								.applyTo(part.getControl());
1303
					}
1309
					}
1304
				}
1310
				}
1305
				// for outline
1311
				// for outline

Return to bug 199283