|
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 |
} |