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

Collapse All | Expand All

(-)src/org/eclipse/mylyn/internal/tasks/ui/wizards/ScreenshotAttachmentPage.java (-2 / +14 lines)
Lines 885-890 Link Here
885
885
886
	private final List<GrabPoint> grabPoints = new ArrayList<GrabPoint>(8);
886
	private final List<GrabPoint> grabPoints = new ArrayList<GrabPoint>(8);
887
887
888
	private boolean dirty;
889
888
	/**
890
	/**
889
	 * Creates the final screenshot
891
	 * Creates the final screenshot
890
	 * 
892
	 * 
Lines 904-915 Link Here
904
		}
906
		}
905
		gc.dispose();
907
		gc.dispose();
906
908
909
		this.dirty = false;
910
907
		return screenshot;
911
		return screenshot;
908
	}
912
	}
909
913
910
	private void markAttachmentDirty() {
914
	private void markAttachmentDirty() {
911
		NewAttachmentWizard wizard = (NewAttachmentWizard) getWizard();
915
		// API 3.0 remove
912
		((ImageAttachment) wizard.getAttachment()).markDirty();
916
		if (getWizard() instanceof NewAttachmentWizard) {
917
			NewAttachmentWizard wizard = (NewAttachmentWizard) getWizard();
918
			((ImageAttachment) wizard.getAttachment()).markDirty();
919
		}
920
		this.dirty = true;
921
	}
922
923
	public boolean isDirty() {
924
		return dirty;
913
	}
925
	}
914
926
915
}
927
}
(-)src/org/eclipse/mylyn/internal/tasks/ui/wizards/InputAttachmentSourcePage.java (-12 / +47 lines)
Lines 35-40 Link Here
35
import org.eclipse.jface.viewers.TreeViewer;
35
import org.eclipse.jface.viewers.TreeViewer;
36
import org.eclipse.jface.wizard.IWizardPage;
36
import org.eclipse.jface.wizard.IWizardPage;
37
import org.eclipse.jface.wizard.WizardPage;
37
import org.eclipse.jface.wizard.WizardPage;
38
import org.eclipse.mylyn.internal.tasks.core.AbstractTaskAttachmentSource;
39
import org.eclipse.mylyn.internal.tasks.core.TaskAttachment;
38
import org.eclipse.mylyn.tasks.ui.TasksUiPlugin;
40
import org.eclipse.mylyn.tasks.ui.TasksUiPlugin;
39
import org.eclipse.swt.SWT;
41
import org.eclipse.swt.SWT;
40
import org.eclipse.swt.dnd.Clipboard;
42
import org.eclipse.swt.dnd.Clipboard;
Lines 55-61 Link Here
55
import org.eclipse.swt.widgets.Text;
57
import org.eclipse.swt.widgets.Text;
56
import org.eclipse.ui.model.WorkbenchContentProvider;
58
import org.eclipse.ui.model.WorkbenchContentProvider;
57
import org.eclipse.ui.model.WorkbenchLabelProvider;
59
import org.eclipse.ui.model.WorkbenchLabelProvider;
58
import org.eclipse.ui.views.navigator.ResourceSorter;
60
import org.eclipse.ui.views.navigator.ResourceComparator;
59
61
60
/**
62
/**
61
 * A wizard to input the source of the attachment.
63
 * A wizard to input the source of the attachment.
Lines 67-73 Link Here
67
 * @author Jeff Pound - modified for attachment input
69
 * @author Jeff Pound - modified for attachment input
68
 * @author Chris Aniszczyk <caniszczyk@gmail.com> - bug 209572
70
 * @author Chris Aniszczyk <caniszczyk@gmail.com> - bug 209572
69
 */
71
 */
70
@SuppressWarnings("deprecation")
71
public class InputAttachmentSourcePage extends WizardPage {
72
public class InputAttachmentSourcePage extends WizardPage {
72
73
73
	// constants
74
	// constants
Lines 109-116 Link Here
109
110
110
	private TreeViewer treeViewer;
111
	private TreeViewer treeViewer;
111
112
112
	private final NewAttachmentWizard wizard;
113
114
	private String clipboardContents;
113
	private String clipboardContents;
115
114
116
	private boolean initUseClipboard = false;
115
	private boolean initUseClipboard = false;
Lines 119-127 Link Here
119
118
120
	private final String S_LAST_SELECTION = "lastSelection"; //$NON-NLS-1$
119
	private final String S_LAST_SELECTION = "lastSelection"; //$NON-NLS-1$
121
120
121
	private TaskAttachment taskAttachment;
122
122
	public InputAttachmentSourcePage(NewAttachmentWizard wizard) {
123
	public InputAttachmentSourcePage(NewAttachmentWizard wizard) {
123
		super("InputAttachmentPage");
124
		super("InputAttachmentPage");
124
		this.wizard = wizard;
125
		setTitle("Select attachment source");
125
		setTitle("Select attachment source");
126
		setDescription("Clipboard contents are for text attachments only.");
126
		setDescription("Clipboard contents are for text attachments only.");
127
		// setMessage("Please select the source for the attachment");
127
		// setMessage("Please select the source for the attachment");
Lines 177-187 Link Here
177
177
178
	@Override
178
	@Override
179
	public IWizardPage getNextPage() {
179
	public IWizardPage getNextPage() {
180
		if (taskAttachment != null) {
181
			taskAttachment.setSource(getSource());
182
		}
180
		if (getInputMethod() == SCREENSHOT) {
183
		if (getInputMethod() == SCREENSHOT) {
181
			return wizard.getPage("ScreenShotAttachment");
184
			return getWizard().getPage("ScreenShotAttachment");
182
		} else {
185
		} else {
183
			saveDialogSettings();
186
			saveDialogSettings();
184
			return wizard.getNextPage(this);
187
			return getWizard().getNextPage(this);
185
		}
188
		}
186
	}
189
	}
187
190
Lines 232-238 Link Here
232
		gd = new GridData(GridData.FILL_HORIZONTAL);
235
		gd = new GridData(GridData.FILL_HORIZONTAL);
233
		gd.widthHint = SIZING_TEXT_FIELD_WIDTH;
236
		gd.widthHint = SIZING_TEXT_FIELD_WIDTH;
234
		fileNameField.setLayoutData(gd);
237
		fileNameField.setLayoutData(gd);
235
		fileNameField.setText(wizard.getAttachment().getFilePath());
238
		if (getWizard() instanceof NewAttachmentWizard) {
239
			fileNameField.setText(((NewAttachmentWizard) getWizard()).getAttachment().getFilePath());
240
		}
236
241
237
		fileBrowseButton = new Button(composite, SWT.PUSH);
242
		fileBrowseButton = new Button(composite, SWT.PUSH);
238
		fileBrowseButton.setText("Browse...");
243
		fileBrowseButton.setText("Browse...");
Lines 366-372 Link Here
366
								treeViewer.expandToLevel(res, 1);
371
								treeViewer.expandToLevel(res, 1);
367
							}
372
							}
368
						} else if (res instanceof IFile) {
373
						} else if (res instanceof IFile) {
369
							wizard.showPage(getNextPage());
374
							getContainer().showPage(getNextPage());
370
						}
375
						}
371
					}
376
					}
372
				}
377
				}
Lines 393-399 Link Here
393
398
394
		treeViewer.setLabelProvider(new WorkbenchLabelProvider());
399
		treeViewer.setLabelProvider(new WorkbenchLabelProvider());
395
		treeViewer.setContentProvider(new WorkbenchContentProvider());
400
		treeViewer.setContentProvider(new WorkbenchContentProvider());
396
		treeViewer.setSorter(new ResourceSorter(ResourceSorter.NAME));
401
		treeViewer.setComparator(new ResourceComparator(ResourceComparator.NAME));
397
		treeViewer.setInput(ResourcesPlugin.getWorkspace().getRoot());
402
		treeViewer.setInput(ResourcesPlugin.getWorkspace().getRoot());
398
	}
403
	}
399
404
Lines 457-463 Link Here
457
		}
462
		}
458
463
459
		setPageComplete(attachmentFound);
464
		setPageComplete(attachmentFound);
460
		wizard.getAttachment().setFilePath(getAbsoluteAttachmentPath());
465
		if (getWizard() instanceof NewAttachmentWizard) {
466
			((NewAttachmentWizard) getWizard()).getAttachment().setFilePath(getAbsoluteAttachmentPath());
467
		}
468
		// API 3.0 set attachment source
461
469
462
		if (showError) {
470
		if (showError) {
463
			setErrorMessage(error);
471
			setErrorMessage(error);
Lines 565-571 Link Here
565
		if (fileNameField != null) {
573
		if (fileNameField != null) {
566
			return fileNameField.getText();
574
			return fileNameField.getText();
567
		}
575
		}
568
		return wizard.getAttachment().getFilePath();
576
		if (getWizard() instanceof NewAttachmentWizard) {
577
			return ((NewAttachmentWizard) getWizard()).getAttachment().getFilePath();
578
		}
579
		return null;
569
	}
580
	}
570
581
571
	public String getAbsoluteAttachmentPath() {
582
	public String getAbsoluteAttachmentPath() {
Lines 676-679 Link Here
676
		return section;
687
		return section;
677
	}
688
	}
678
689
690
	public AbstractTaskAttachmentSource getSource() {
691
		switch (getInputMethod()) {
692
		case CLIPBOARD:
693
			return new TaskAttachmentWizard.ClipboardSource();
694
		case WORKSPACE:
695
			IResource[] resources = getResources(treeViewer.getSelection());
696
			if (resources.length > 0) {
697
				return new TaskAttachmentWizard.FileSource(resources[0].getLocation().toFile());
698
			} else {
699
				return null;
700
			}
701
		default: // FILE
702
			return new TaskAttachmentWizard.FileSource(new File(getAttachmentFilePath()));
703
		}
704
	}
705
706
	public TaskAttachment getTaskAttachment() {
707
		return taskAttachment;
708
	}
709
710
	public void setTaskAttachment(TaskAttachment taskAttachment) {
711
		this.taskAttachment = taskAttachment;
712
	}
713
679
}
714
}
(-)src/org/eclipse/mylyn/internal/tasks/ui/SubmitTaskAttachmentJob.java (+109 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;
10
11
import org.eclipse.core.runtime.IProgressMonitor;
12
import org.eclipse.core.runtime.IStatus;
13
import org.eclipse.core.runtime.jobs.Job;
14
import org.eclipse.mylyn.internal.tasks.core.TaskAttachment;
15
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
16
import org.eclipse.mylyn.tasks.core.AbstractTask;
17
import org.eclipse.mylyn.tasks.core.TaskRepository;
18
19
/**
20
 * @author Steffen Pingel
21
 */
22
public class SubmitTaskAttachmentJob extends Job {
23
24
	private static final String LABEL_JOB_SUBMIT = "Submitting to repository";
25
26
	private final TaskAttachment taskAttachment;
27
28
	private final AbstractRepositoryConnector connector;
29
30
	private final TaskRepository taskRepository;
31
32
	private AbstractTask task;
33
34
	public SubmitTaskAttachmentJob(AbstractRepositoryConnector connector, TaskRepository taskRepository,
35
			TaskAttachment taskAttachment) {
36
		super(LABEL_JOB_SUBMIT);
37
		this.connector = connector;
38
		this.taskRepository = taskRepository;
39
		this.taskAttachment = taskAttachment;
40
	}
41
42
	@Override
43
	public IStatus run(IProgressMonitor monitor) {
44
		return null;
45
//		try {
46
//			if (monitor == null) {
47
//				monitor = new NullProgressMonitor();
48
//			}
49
//			monitor.beginTask("Attaching file...", 2);
50
//			task.setSubmitting(true);
51
//			task.setSynchronizationState(RepositoryTaskSyncState.OUTGOING);
52
//
53
//			if (screenshotMode || InputAttachmentSourcePage.SCREENSHOT_LABEL.equals(path)) {
54
//				((ImageAttachment) taskAttachment).ensureImageFileWasCreated();
55
//			} else if (InputAttachmentSourcePage.CLIPBOARD_LABEL.equals(path)) {
56
//				String contents = inputPage.getClipboardContents();
57
//				if (contents == null) {
58
//					throw new InvocationTargetException(new CoreException(new RepositoryStatus(IStatus.ERROR,
59
//							TasksUiPlugin.ID_PLUGIN, RepositoryStatus.ERROR_INTERNAL, "Clipboard is empty", null)));
60
//				}
61
//				taskAttachment.setContent(contents.getBytes());
62
//				taskAttachment.setFilename(CLIPBOARD_FILENAME);
63
//			} else {
64
//				File file = new File(path);
65
//				taskAttachment.setFile(file);
66
//				taskAttachment.setFilename(file.getName());
67
//			}
68
//
69
//			attachmentHandler.uploadAttachment(taskRepository, task, taskAttachment, taskAttachment.getComment(),
70
//					new SubProgressMonitor(monitor, 1));
71
//
72
//			if (monitor.isCanceled()) {
73
//				throw new OperationCanceledException();
74
//			}
75
//
76
//			if (attachContext && connector.getAttachmentHandler() != null) {
77
//				connector.getAttachmentHandler().attachContext(taskRepository, task, "",
78
//						new SubProgressMonitor(monitor, 1));
79
//			}
80
//		} catch (CoreException e) {
81
//			return e.getStatus();
82
//		} finally {
83
//			task.setSubmitting(false);
84
//			task.setSynchronizationState(RepositoryTaskSyncState.SYNCHRONIZED);
85
//
86
//			monitor.done();
87
//		}
88
	}
89
90
//	private void synchronizeTask() {
91
//		TasksUiPlugin.getSynchronizationManager().synchronize(connector, task, false, new JobChangeAdapter() {
92
//			@Override
93
//			public void done(final IJobChangeEvent event) {
94
//				PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
95
//					public void run() {
96
//						if (event.getResult().getException() != null) {
97
//
98
//							MessageDialog.openError(Display.getDefault().getActiveShell(),
99
//									ITasksUiConstants.TITLE_DIALOG, event.getResult().getMessage());
100
//
101
//						}
102
//						forceRefreshInplace(task);
103
//					}
104
//				});
105
//			}
106
//		});
107
//	}
108
109
}
(-)src/org/eclipse/mylyn/internal/tasks/ui/wizards/TaskAttachmentPage.java (+302 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.wizards;
10
11
import java.util.HashMap;
12
import java.util.Iterator;
13
import java.util.LinkedList;
14
import java.util.List;
15
import java.util.Locale;
16
import java.util.Map;
17
18
import org.eclipse.jface.wizard.IWizardPage;
19
import org.eclipse.jface.wizard.WizardPage;
20
import org.eclipse.mylyn.internal.tasks.core.TaskAttachment;
21
import org.eclipse.mylyn.internal.tasks.ui.TasksUiImages;
22
import org.eclipse.swt.SWT;
23
import org.eclipse.swt.events.ModifyEvent;
24
import org.eclipse.swt.events.ModifyListener;
25
import org.eclipse.swt.events.SelectionEvent;
26
import org.eclipse.swt.events.SelectionListener;
27
import org.eclipse.swt.layout.GridData;
28
import org.eclipse.swt.layout.GridLayout;
29
import org.eclipse.swt.widgets.Button;
30
import org.eclipse.swt.widgets.Combo;
31
import org.eclipse.swt.widgets.Composite;
32
import org.eclipse.swt.widgets.Label;
33
import org.eclipse.swt.widgets.Text;
34
35
/**
36
 * A wizard page to enter details of a new attachment.
37
 * 
38
 * @author Jeff Pound
39
 * @author Mik Kersten
40
 */
41
public class TaskAttachmentPage extends WizardPage {
42
43
	private final TaskAttachment attachment;
44
45
	private Text filePath;
46
47
	private Text attachmentDesc;
48
49
	private Text attachmentComment;
50
51
	private Button isPatchButton;
52
53
	private Button attachContextButton;
54
55
	private Combo contentTypeList;
56
57
	private boolean supportsDescription = true;
58
59
	private static List<String> contentTypes;
60
61
	private static Map<String, String> extensions2Types;
62
63
	static {
64
		/* For UI */
65
		contentTypes = new LinkedList<String>();
66
		contentTypes.add("text/plain");
67
		contentTypes.add("text/html");
68
		contentTypes.add("application/xml");
69
		contentTypes.add("image/gif");
70
		contentTypes.add("image/jpeg");
71
		contentTypes.add("image/png");
72
		contentTypes.add("application/octet-stream");
73
74
		/* For auto-detect */
75
		extensions2Types = new HashMap<String, String>();
76
		extensions2Types.put("txt", "text/plain");
77
		extensions2Types.put("html", "text/html");
78
		extensions2Types.put("htm", "text/html");
79
		extensions2Types.put("jpg", "image/jpeg");
80
		extensions2Types.put("jpeg", "image/jpeg");
81
		extensions2Types.put("gif", "image/gif");
82
		extensions2Types.put("png", "image/png");
83
		extensions2Types.put("xml", "application/xml");
84
		extensions2Types.put("zip", "application/octet-stream");
85
		extensions2Types.put("tar", "application/octet-stream");
86
		extensions2Types.put("gz", "application/octet-stream");
87
	}
88
89
	protected TaskAttachmentPage(TaskAttachment attachment) {
90
		super("AttachmentDetails");
91
		setTitle("Attachment Details");
92
		setMessage("Enter a description and verify the content type of the attachment");
93
		this.attachment = attachment;
94
	}
95
96
	public void createControl(Composite parent) {
97
		Composite composite = new Composite(parent, SWT.NONE);
98
		GridLayout gridLayout = new GridLayout();
99
		gridLayout.numColumns = 3;
100
		composite.setLayout(gridLayout);
101
		setControl(composite);
102
103
		composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
104
		composite.setLayout(new GridLayout(3, false));
105
106
		final TaskAttachmentPage thisPage = this;
107
108
		new Label(composite, SWT.NONE).setText("File");
109
		filePath = new Text(composite, SWT.BORDER);
110
		filePath.setEditable(false);
111
		filePath.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1));
112
113
		if (supportsDescription) {
114
			new Label(composite, SWT.NONE).setText("Description");
115
			attachmentDesc = new Text(composite, SWT.BORDER);
116
			attachmentDesc.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1));
117
118
			attachmentDesc.addModifyListener(new ModifyListener() {
119
				public void modifyText(ModifyEvent e) {
120
					if ("".equals(attachmentDesc.getText().trim())) {
121
						thisPage.setErrorMessage("Description required");
122
					} else {
123
						if (!"".equals(filePath.getText())) {
124
							thisPage.setPageComplete(true);
125
							thisPage.setErrorMessage(null);
126
						}
127
					}
128
				}
129
130
			});
131
		}
132
133
		Label label = new Label(composite, SWT.NONE);
134
		label.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, false));
135
		label.setText("Comment");
136
		attachmentComment = new Text(composite, SWT.V_SCROLL | SWT.BORDER | SWT.WRAP);
137
		attachmentComment.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
138
139
		new Label(composite, SWT.NONE).setText("Content Type");// .setBackground(parent.getBackground());
140
141
		contentTypeList = new Combo(composite, SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY);
142
		contentTypeList.setLayoutData(new GridData(SWT.DEFAULT, SWT.DEFAULT, false, false, 2, 1));
143
		final HashMap<String, Integer> contentTypeIndices = new HashMap<String, Integer>();
144
		Iterator<String> iter = contentTypes.iterator();
145
		int i = 0;
146
		while (iter.hasNext()) {
147
			String next = iter.next();
148
			contentTypeList.add(next);
149
			contentTypeIndices.put(next, new Integer(i));
150
			i++;
151
		}
152
153
		/* Update attachment on select content type */
154
		contentTypeList.addSelectionListener(new SelectionListener() {
155
			public void widgetDefaultSelected(SelectionEvent e) {
156
				// ignore
157
			}
158
159
			public void widgetSelected(SelectionEvent e) {
160
				attachment.setContentType(contentTypeList.getItem(contentTypeList.getSelectionIndex()));
161
			}
162
		});
163
		contentTypeList.select(0);
164
		attachment.setContentType(contentTypeList.getItem(0));
165
166
		// TODO: is there a better way to pad?
167
		new Label(composite, SWT.NONE);
168
169
		isPatchButton = new Button(composite, SWT.CHECK);
170
		isPatchButton.setLayoutData(new GridData(SWT.DEFAULT, SWT.DEFAULT, false, false, 2, 1));
171
		isPatchButton.setText("Patch");
172
173
		// TODO: is there a better way to pad?
174
		new Label(composite, SWT.NONE);
175
176
		attachContextButton = new Button(composite, SWT.CHECK);
177
		attachContextButton.setLayoutData(new GridData(SWT.DEFAULT, SWT.DEFAULT, false, false, 2, 1));
178
		attachContextButton.setText("Attach Context");
179
		attachContextButton.setImage(TasksUiImages.getImage(TasksUiImages.CONTEXT_ATTACH));
180
		attachContextButton.setEnabled((((NewAttachmentWizard) getWizard()).hasContext()));
181
182
		/*
183
		 * Attachment file name listener, update the local attachment
184
		 * accordingly
185
		 */
186
		filePath.addModifyListener(new ModifyListener() {
187
			public void modifyText(ModifyEvent e) {
188
				// Determine type by extension
189
				int index = filePath.getText().lastIndexOf(".");
190
				if (index > 0 && index < filePath.getText().length()) {
191
					String ext = filePath.getText().substring(index + 1);
192
					String type = extensions2Types.get(ext.toLowerCase(Locale.ENGLISH));
193
					if (type != null) {
194
						contentTypeList.select(contentTypeIndices.get(type));
195
						attachment.setContentType(type);
196
					}
197
				}
198
199
				// check page completenes
200
				if (attachmentDesc != null && "".equals(attachmentDesc.getText())) {
201
					thisPage.setErrorMessage("Description required");
202
				} else {
203
					if (!"".equals(filePath.getText())) {
204
						thisPage.setPageComplete(true);
205
						thisPage.setErrorMessage(null);
206
					}
207
				}
208
			}
209
		});
210
211
		filePath.setText(attachment.getName() == null ? "" : attachment.getName()); //$NON-NLS-1$
212
213
		/* Listener for isPatch */
214
		isPatchButton.addSelectionListener(new SelectionListener() {
215
			private int lastSelected;
216
217
			public void widgetDefaultSelected(SelectionEvent e) {
218
				// ignore
219
			}
220
221
			public void widgetSelected(SelectionEvent e) {
222
				attachment.setPatch(isPatchButton.getSelection());
223
				if (isPatchButton.getSelection()) {
224
					lastSelected = contentTypeList.getSelectionIndex();
225
					contentTypeList.select(0);
226
					contentTypeList.setEnabled(false);
227
					if (attachContextButton.isEnabled()) {
228
						attachContextButton.setSelection(true);
229
					}
230
				} else {
231
					contentTypeList.setEnabled(true);
232
					contentTypeList.select(lastSelected);
233
				}
234
			}
235
		});
236
237
		thisPage.setErrorMessage(null);
238
	}
239
240
	@Override
241
	public boolean isPageComplete() {
242
		return !"".equals(filePath.getText().trim())
243
				&& (attachmentDesc == null || !"".equals(attachmentDesc.getText().trim()));
244
	}
245
246
	public void populateAttachment() {
247
		if (attachmentDesc != null) {
248
			attachment.setDescription(attachmentDesc.getText());
249
		}
250
		attachment.setComment(attachmentComment.getText());
251
	}
252
253
	public TaskAttachment getAttachment() {
254
		return attachment;
255
	}
256
257
	public void setFilePath(String path) {
258
		filePath.setText(path);
259
		if (path.endsWith(".patch")) {
260
			isPatchButton.setSelection(true);
261
			if (attachContextButton.isEnabled()) {
262
				attachContextButton.setSelection(true);
263
			}
264
		}
265
	}
266
267
	@Override
268
	public IWizardPage getNextPage() {
269
		populateAttachment();
270
		// TODO implement preview
271
//		PreviewAttachmentPage page = new PreviewAttachmentPage(getAttachment());
272
//		page.setWizard(getWizard());
273
//		return page;
274
		return null;
275
	}
276
277
	public boolean getAttachContext() {
278
		return attachContextButton.getSelection();
279
	}
280
281
	public void setContentType() {
282
		String type = attachment.getContentType();
283
		String[] typeList = contentTypeList.getItems();
284
		for (int i = 0; i < typeList.length; i++) {
285
			if (typeList[i].equals(type)) {
286
				contentTypeList.select(i);
287
				contentTypeList.setEnabled(false);
288
				isPatchButton.setEnabled(false);
289
				return;
290
			}
291
		}
292
	}
293
294
	public boolean supportsDescription() {
295
		return supportsDescription;
296
	}
297
298
	public void setSupportsDescription(boolean supportsDescription) {
299
		this.supportsDescription = supportsDescription;
300
	}
301
302
}
(-).refactorings/2008/3/11/refactorings.history (+3 lines)
Added Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<session version="1.0">&#x0A;<refactoring comment="Copy 1 elements(s) to &apos;org.eclipse.mylyn.internal.tasks.ui.wizards.NewAttachmentWizard.java&apos;&#x0A;- Original project: &apos;org.eclipse.mylyn.tasks.ui&apos;&#x0A;- Destination element: &apos;org.eclipse.mylyn.internal.tasks.ui.wizards.NewAttachmentWizard.java&apos;&#x0A;- Original element: &apos;org.eclipse.mylyn.internal.tasks.ui.wizards.NewAttachmentWizard.java&apos;" description="Copy compilation unit" destination="/src&lt;org.eclipse.mylyn.internal.tasks.ui.wizards{NewAttachmentWizard.java" element1="/src&lt;org.eclipse.mylyn.internal.tasks.ui.wizards{NewAttachmentWizard.java" files="0" flags="589830" folders="0" id="org.eclipse.jdt.ui.copy" policy="org.eclipse.jdt.ui.copyResources" stamp="1205637874637" units="1" version="1.0"/>&#x0A;<refactoring comment="Inline local variable &apos;org.eclipse.mylyn.internal.tasks.ui.wizards.TaskAttachmentWizard.TaskAttachmentWizard().section&apos; in &apos;org.eclipse.mylyn.internal.tasks.ui.wizards.TaskAttachmentWizard.TaskAttachmentWizard()&apos;&#x0A;- Original project: &apos;org.eclipse.mylyn.tasks.ui&apos;&#x0A;- Original element: &apos;org.eclipse.mylyn.internal.tasks.ui.wizards.TaskAttachmentWizard.TaskAttachmentWizard().section&apos;" description="Inline local variable &apos;section&apos;" id="org.eclipse.jdt.ui.inline.temp" input="/src&lt;org.eclipse.mylyn.internal.tasks.ui.wizards{TaskAttachmentWizard.java" selection="3849 59" stamp="1205638311233" version="1.0"/>&#x0A;<refactoring comment="Inline local variable &apos;org.eclipse.mylyn.internal.tasks.ui.wizards.TaskAttachmentWizard.TaskAttachmentWizard().workbenchSettings&apos; in &apos;org.eclipse.mylyn.internal.tasks.ui.wizards.TaskAttachmentWizard.TaskAttachmentWizard()&apos;&#x0A;- Original project: &apos;org.eclipse.mylyn.tasks.ui&apos;&#x0A;- Original element: &apos;org.eclipse.mylyn.internal.tasks.ui.wizards.TaskAttachmentWizard.TaskAttachmentWizard().workbenchSettings&apos;" description="Inline local variable &apos;workbenchSettings&apos;" id="org.eclipse.jdt.ui.inline.temp" input="/src&lt;org.eclipse.mylyn.internal.tasks.ui.wizards{TaskAttachmentWizard.java" selection="3763 66" stamp="1205638314204" version="1.0"/>&#x0A;<refactoring comment="Copy 1 elements(s) to &apos;org.eclipse.mylyn.internal.tasks.ui.wizards.ColorSelectionWindow.java&apos;&#x0A;- Original project: &apos;org.eclipse.mylyn.tasks.ui&apos;&#x0A;- Destination element: &apos;org.eclipse.mylyn.internal.tasks.ui.wizards.ColorSelectionWindow.java&apos;&#x0A;- Original element: &apos;org.eclipse.mylyn.internal.tasks.ui.wizards.InputAttachmentSourcePage.java&apos;" description="Copy compilation unit" destination="/src&lt;org.eclipse.mylyn.internal.tasks.ui.wizards{ColorSelectionWindow.java" element1="/src&lt;org.eclipse.mylyn.internal.tasks.ui.wizards{InputAttachmentSourcePage.java" files="0" flags="589830" folders="0" id="org.eclipse.jdt.ui.copy" policy="org.eclipse.jdt.ui.copyResources" stamp="1205639811155" units="1" version="1.0"/>&#x0A;<refactoring comment="Copy 1 elements(s) to &apos;org.eclipse.mylyn.internal.tasks.ui.wizards.InputAttachmentSourcePage.java&apos;&#x0A;- Original project: &apos;org.eclipse.mylyn.tasks.ui&apos;&#x0A;- Destination element: &apos;org.eclipse.mylyn.internal.tasks.ui.wizards.InputAttachmentSourcePage.java&apos;&#x0A;- Original element: &apos;org.eclipse.mylyn.internal.tasks.ui.wizards.NewAttachmentPage.java&apos;" description="Copy compilation unit" destination="/src&lt;org.eclipse.mylyn.internal.tasks.ui.wizards{InputAttachmentSourcePage.java" element1="/src&lt;org.eclipse.mylyn.internal.tasks.ui.wizards{NewAttachmentPage.java" files="0" flags="589830" folders="0" id="org.eclipse.jdt.ui.copy" policy="org.eclipse.jdt.ui.copyResources" stamp="1205643619044" units="1" version="1.0"/>&#x0A;<refactoring comment="Copy 1 elements(s) to &apos;org.eclipse.mylyn.internal.tasks.ui.wizards.NewTaskPage.java&apos;&#x0A;- Original project: &apos;org.eclipse.mylyn.tasks.ui&apos;&#x0A;- Destination element: &apos;org.eclipse.mylyn.internal.tasks.ui.wizards.NewTaskPage.java&apos;&#x0A;- Original element: &apos;org.eclipse.mylyn.internal.tasks.ui.wizards.PreviewAttachmentPage.java&apos;" description="Copy compilation unit" destination="/src&lt;org.eclipse.mylyn.internal.tasks.ui.wizards{NewTaskPage.java" element1="/src&lt;org.eclipse.mylyn.internal.tasks.ui.wizards{PreviewAttachmentPage.java" files="0" flags="589830" folders="0" id="org.eclipse.jdt.ui.copy" policy="org.eclipse.jdt.ui.copyResources" stamp="1205643880147" units="1" version="1.0"/>&#x0A;<refactoring accessors="true" comment="Delete 1 element(s) from project &apos;org.eclipse.mylyn.tasks.ui&apos;&#x0A;- Original project: &apos;org.eclipse.mylyn.tasks.ui&apos;&#x0A;- Original element: &apos;org.eclipse.mylyn.internal.tasks.ui.wizards.PreviewTaskAttachmentPage.java&apos;" description="Delete element" element1="/src&lt;org.eclipse.mylyn.internal.tasks.ui.wizards{PreviewTaskAttachmentPage.java" elements="1" flags="589830" id="org.eclipse.jdt.ui.delete" resources="0" stamp="1205643958946" subPackages="false" version="1.0"/>&#x0A;<refactoring comment="Extract method &apos;private TaskAttachmentPage createEditPage()&apos; from &apos;org.eclipse.mylyn.internal.tasks.ui.wizards.TaskAttachmentWizard.addPages()&apos; to &apos;org.eclipse.mylyn.internal.tasks.ui.wizards.TaskAttachmentWizard&apos;&#x0A;- Original project: &apos;org.eclipse.mylyn.tasks.ui&apos;&#x0A;- Method name: &apos;createEditPage&apos;&#x0A;- Destination type: &apos;org.eclipse.mylyn.internal.tasks.ui.wizards.TaskAttachmentWizard&apos;&#x0A;- Declared visibility: &apos;private&apos;" comments="false" description="Extract method &apos;createEditPage&apos;" destination="0" exceptions="false" flags="786434" id="org.eclipse.jdt.ui.extract.method" input="/src&lt;org.eclipse.mylyn.internal.tasks.ui.wizards{TaskAttachmentWizard.java" name="createEditPage" replace="false" selection="7109 38" stamp="1205644094274" version="1.0" visibility="2"/>&#x0A;<refactoring accessors="true" comment="Delete 1 element(s) from project &apos;org.eclipse.mylyn.tasks.ui&apos;&#x0A;- Original project: &apos;org.eclipse.mylyn.tasks.ui&apos;&#x0A;- Original element: &apos;org.eclipse.mylyn.internal.tasks.ui.wizards.SelectAttachmentSourcePage.java&apos;" description="Delete element" element1="/src&lt;org.eclipse.mylyn.internal.tasks.ui.wizards{SelectAttachmentSourcePage.java" elements="1" flags="589830" id="org.eclipse.jdt.ui.delete" resources="0" stamp="1205645767648" subPackages="false" version="1.0"/>
3
</session>
(-).refactorings/2008/3/11/refactorings.index (+9 lines)
Added Link Here
1
1205637874637	Copy compilation unit
2
1205638311233	Inline local variable 'section'
3
1205638314204	Inline local variable 'workbenchSettings'
4
1205639811155	Copy compilation unit
5
1205643619044	Copy compilation unit
6
1205643880147	Copy compilation unit
7
1205643958946	Delete element
8
1205644094274	Extract method 'createEditPage'
9
1205645767648	Delete element
(-)src/org/eclipse/mylyn/internal/tasks/ui/wizards/TaskAttachmentWizard.java (+310 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.wizards;
10
11
import java.io.ByteArrayInputStream;
12
import java.io.File;
13
import java.io.FileInputStream;
14
import java.io.FileNotFoundException;
15
import java.io.FileOutputStream;
16
import java.io.IOException;
17
import java.io.InputStream;
18
import java.lang.reflect.InvocationTargetException;
19
20
import org.eclipse.core.runtime.CoreException;
21
import org.eclipse.core.runtime.IProgressMonitor;
22
import org.eclipse.core.runtime.IStatus;
23
import org.eclipse.core.runtime.Status;
24
import org.eclipse.jface.operation.IRunnableWithProgress;
25
import org.eclipse.jface.window.Window;
26
import org.eclipse.jface.wizard.Wizard;
27
import org.eclipse.mylyn.internal.tasks.core.AbstractTaskAttachmentSource;
28
import org.eclipse.mylyn.internal.tasks.core.TaskAttachment;
29
import org.eclipse.mylyn.internal.tasks.ui.SubmitTaskAttachmentJob;
30
import org.eclipse.mylyn.internal.tasks.ui.TasksUiImages;
31
import org.eclipse.mylyn.monitor.core.StatusHandler;
32
import org.eclipse.mylyn.tasks.core.AbstractAttachmentHandler;
33
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
34
import org.eclipse.mylyn.tasks.core.RepositoryStatus;
35
import org.eclipse.mylyn.tasks.core.TaskRepository;
36
import org.eclipse.mylyn.tasks.ui.TasksUiPlugin;
37
import org.eclipse.mylyn.tasks.ui.TasksUiUtil;
38
import org.eclipse.swt.SWT;
39
import org.eclipse.swt.dnd.Clipboard;
40
import org.eclipse.swt.dnd.TextTransfer;
41
import org.eclipse.swt.graphics.Image;
42
import org.eclipse.swt.graphics.ImageData;
43
import org.eclipse.swt.graphics.ImageLoader;
44
import org.eclipse.ui.PlatformUI;
45
46
/**
47
 * A wizard to add a new attachment to a task report.
48
 * 
49
 * @since 3.0
50
 * @author Jeff Pound
51
 * @author Steffen Pingel
52
 */
53
public class TaskAttachmentWizard extends Wizard {
54
55
	static class ClipboardSource extends AbstractTaskAttachmentSource {
56
57
		@Override
58
		public InputStream createInputStream(IProgressMonitor monitor) throws CoreException {
59
			String content = getContent();
60
			if (content != null) {
61
				return new ByteArrayInputStream(content.getBytes());
62
			}
63
			throw new CoreException(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, "Invalid content type."));
64
		}
65
66
		protected String getContent() {
67
			Clipboard clipboard = new Clipboard(PlatformUI.getWorkbench().getDisplay());
68
			Object o = clipboard.getContents(TextTransfer.getInstance());
69
			clipboard.dispose();
70
			if (o instanceof String) {
71
				return (String) o;
72
			}
73
			return null;
74
		}
75
76
		@Override
77
		public String getContentType() {
78
			return "text/plain";
79
		}
80
81
		@Override
82
		public long getLength() {
83
			String content = getContent();
84
			if (content != null) {
85
				return content.length();
86
			}
87
			return -1;
88
		}
89
90
		@Override
91
		public String getName() {
92
			return "clipboard.txt";
93
		}
94
95
		@Override
96
		public boolean isLocal() {
97
			return true;
98
		}
99
100
	};
101
102
	static class FileSource extends AbstractTaskAttachmentSource {
103
104
		private final File file;
105
106
		public FileSource(File file) {
107
			this.file = file;
108
		}
109
110
		@Override
111
		public InputStream createInputStream(IProgressMonitor monitor) throws CoreException {
112
			try {
113
				return new FileInputStream(file);
114
			} catch (FileNotFoundException e) {
115
				throw new CoreException(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, e.getMessage(), e));
116
			}
117
		}
118
119
		@Override
120
		public String getContentType() {
121
			return null;
122
		}
123
124
		@Override
125
		public long getLength() {
126
			return file.length();
127
		}
128
129
		@Override
130
		public String getName() {
131
			return file.getName();
132
		}
133
134
		@Override
135
		public boolean isLocal() {
136
			return true;
137
		}
138
139
	}
140
141
	static class ImageSource extends AbstractTaskAttachmentSource {
142
143
		private File file;
144
145
		private final IImageCreator imageCreator;
146
147
		public ImageSource(IImageCreator imageCreator) {
148
			this.imageCreator = imageCreator;
149
		}
150
151
		@Override
152
		public InputStream createInputStream(IProgressMonitor monitor) throws CoreException {
153
			// TODO check dirty status
154
			Image image = imageCreator.createImage();
155
			try {
156
				file = File.createTempFile("screenshot", ".jpg");
157
				file.deleteOnExit();
158
				ImageLoader loader = new ImageLoader();
159
				loader.data = new ImageData[] { image.getImageData() };
160
				// create image in memory?
161
				loader.save(new FileOutputStream(file), SWT.IMAGE_JPEG);
162
				return new FileInputStream(file);
163
			} catch (IOException e) {
164
				throw new CoreException(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, e.getMessage(), e));
165
			} finally {
166
				image.dispose();
167
			}
168
		}
169
170
		@Override
171
		public String getContentType() {
172
			return "image/jpeg";
173
		}
174
175
		@Override
176
		public long getLength() {
177
			return (file != null) ? file.length() : -1;
178
		}
179
180
		@Override
181
		public String getName() {
182
			return "screenshot.jpg";
183
		}
184
185
		@Override
186
		public boolean isLocal() {
187
			return true;
188
		}
189
190
	}
191
192
	public enum Mode {
193
		DEFAULT, SCREENSHOT
194
	}
195
196
	static class StringSource extends ClipboardSource {
197
198
		private final String content;
199
200
		public StringSource(String content) {
201
			this.content = content;
202
		}
203
204
		@Override
205
		protected String getContent() {
206
			return content;
207
		}
208
209
	}
210
211
	private static final String DIALOG_SETTINGS_KEY = "AttachmentWizard";
212
213
	private Mode mode = Mode.DEFAULT;
214
215
	private final TaskAttachment taskAttachment;
216
217
	private final TaskRepository taskRepository;
218
219
	public TaskAttachmentWizard(TaskRepository taskRepository, TaskAttachment taskAttachment) {
220
		this.taskRepository = taskRepository;
221
		this.taskAttachment = taskAttachment;
222
223
		if (mode == Mode.SCREENSHOT) {
224
			setWindowTitle("Attach Screenshot");
225
			setDefaultPageImageDescriptor(TasksUiImages.BANNER_SCREENSHOT);
226
		} else {
227
			setWindowTitle("Add Attachment");
228
			setDefaultPageImageDescriptor(TasksUiImages.BANNER_REPOSITORY);
229
		}
230
231
		setNeedsProgressMonitor(true);
232
		setDialogSettings(TasksUiPlugin.getDefault().getDialogSettings().getSection(DIALOG_SETTINGS_KEY));
233
	}
234
235
	@Override
236
	public void addPages() {
237
		if (taskAttachment.getSource() == null) {
238
			if (mode == Mode.SCREENSHOT) {
239
				ScreenshotAttachmentPage shotPage = new ScreenshotAttachmentPage();
240
				taskAttachment.setSource(new ImageSource(shotPage));
241
				addPage(shotPage);
242
			} else {
243
				InputAttachmentSourcePage inputPage = new InputAttachmentSourcePage(null);
244
				inputPage.setTaskAttachment(taskAttachment);
245
				addPage(inputPage);
246
			}
247
		}
248
249
		addPage(createEditPage());
250
	}
251
252
	protected TaskAttachmentPage createEditPage() {
253
		return new TaskAttachmentPage(taskAttachment);
254
	}
255
256
	public TaskAttachment getAttachment() {
257
		return taskAttachment;
258
	}
259
260
	private void handleSubmitError(final CoreException exception) {
261
		if (exception.getStatus().getCode() == RepositoryStatus.ERROR_REPOSITORY_LOGIN) {
262
			if (TasksUiUtil.openEditRepositoryWizard(taskRepository) == Window.OK) {
263
				// performFinish();
264
			}
265
		} else {
266
			StatusHandler.displayStatus("Attachment failed", exception.getStatus());
267
		}
268
	}
269
270
	@Override
271
	public boolean performFinish() {
272
//		attachPage.populateAttachment();
273
//		final String path = inputPage.getAbsoluteAttachmentPath();
274
		// upload the attachment
275
		final AbstractRepositoryConnector connector = TasksUiPlugin.getRepositoryManager().getRepositoryConnector(
276
				taskRepository.getConnectorKind());
277
		final AbstractAttachmentHandler attachmentHandler = connector.getAttachmentHandler();
278
		if (attachmentHandler == null) {
279
			return false;
280
		}
281
282
//		final boolean attachContext = attachPage.getAttachContext();
283
284
		final SubmitTaskAttachmentJob job = new SubmitTaskAttachmentJob(connector, taskRepository, taskAttachment);
285
		try {
286
			getContainer().run(true, true, new IRunnableWithProgress() {
287
				public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
288
					job.run(monitor);
289
				}
290
			});
291
		} catch (InvocationTargetException e) {
292
			if (e.getCause() instanceof CoreException) {
293
				handleSubmitError((CoreException) e.getCause());
294
			} else {
295
				StatusHandler.fail(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, "Attachment failure", e));
296
			}
297
			return false;
298
		} catch (InterruptedException e) {
299
			// cancelled
300
			return false;
301
		}
302
303
		return true;
304
	}
305
306
	public void setMode(Mode mode) {
307
		this.mode = mode;
308
	}
309
310
}
(-)src/org/eclipse/mylyn/tasks/core/RepositoryTaskData.java (+1 lines)
Lines 269-274 Link Here
269
		return attachments;
269
		return attachments;
270
	}
270
	}
271
271
272
	// API 3.0 rename to getTaskId()
272
	public String getId() {
273
	public String getId() {
273
		return reportID;
274
		return reportID;
274
	}
275
	}
(-)src/org/eclipse/mylyn/tasks/core/RepositoryTaskAttribute.java (+15 lines)
Lines 156-161 Link Here
156
	 */
156
	 */
157
	public static final String TYPE_TASK_DEPENDENCY = "taskDepenedency";
157
	public static final String TYPE_TASK_DEPENDENCY = "taskDepenedency";
158
158
159
	/**
160
	 * @since 3.0
161
	 */
162
	public static final String TYPE_CONTAINER = "container";
163
164
	/**
165
	 * @since 3.0
166
	 */
167
	public static final String TYPE_COMMENT = "comment";
168
169
	/**
170
	 * @since 3.0
171
	 */
172
	public static final String TYPE_ATTACHMENT = "attachment";
173
159
	private boolean hidden = false;
174
	private boolean hidden = false;
160
175
161
	private boolean isReadOnly = false;
176
	private boolean isReadOnly = false;
(-)src/org/eclipse/mylyn/internal/tasks/core/AbstractAttributeMapper.java (+15 lines)
Lines 15-20 Link Here
15
15
16
import org.eclipse.mylyn.tasks.core.AbstractAttributeFactory;
16
import org.eclipse.mylyn.tasks.core.AbstractAttributeFactory;
17
import org.eclipse.mylyn.tasks.core.RepositoryTaskAttribute;
17
import org.eclipse.mylyn.tasks.core.RepositoryTaskAttribute;
18
import org.eclipse.mylyn.tasks.core.RepositoryTaskData;
18
19
19
/**
20
/**
20
 * @author Steffen Pingel
21
 * @author Steffen Pingel
Lines 108-111 Link Here
108
109
109
	public abstract String getType(RepositoryTaskAttribute taskAttribute);
110
	public abstract String getType(RepositoryTaskAttribute taskAttribute);
110
111
112
	public AbstractTaskAttachment getTaskAttachment(RepositoryTaskAttribute taskAttribute) {
113
		RepositoryTaskData taskData = taskAttribute.getTaskData();
114
		String attachmentId = "";
115
		TaskAttachment attachment = new TaskAttachment(taskData.getRepositoryUrl(), taskData.getRepositoryKind(),
116
				taskData.getId(), attachmentId);
117
		return attachment;
118
	}
119
120
	public AbstractTaskAttachment createTaskAttachment(RepositoryTaskData taskData) {
121
		TaskAttachment attachment = new TaskAttachment(taskData.getRepositoryUrl(), taskData.getRepositoryKind(),
122
				taskData.getId(), "");
123
		return attachment;
124
	}
125
111
}
126
}
(-)src/org/eclipse/mylyn/internal/tasks/core/AbstractTaskAttachment.java (+67 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
package org.eclipse.mylyn.internal.tasks.core;
9
10
import java.io.InputStream;
11
12
import org.eclipse.core.runtime.CoreException;
13
import org.eclipse.core.runtime.IProgressMonitor;
14
15
/**
16
 * @author Steffen Pingel
17
 */
18
public abstract class AbstractTaskAttachment {
19
20
	private final String attachmentId;
21
22
	private final String connectorKind;
23
24
	private final String repositoryUrl;
25
26
	private final String taskId;
27
28
	public AbstractTaskAttachment(String connectorKind, String repositoryUrl, String taskId, String attachmentId) {
29
		this.connectorKind = connectorKind;
30
		this.repositoryUrl = repositoryUrl;
31
		this.taskId = taskId;
32
		this.attachmentId = attachmentId;
33
	}
34
35
	public abstract InputStream createInputStream(IProgressMonitor monitor) throws CoreException;
36
37
	public String getAttachmentId() {
38
		return attachmentId;
39
	}
40
41
	public String getConnectorKind() {
42
		return connectorKind;
43
	}
44
45
	public abstract String getContentType();
46
47
	public abstract String getDescription();
48
49
	public abstract long getLength();
50
51
	public abstract String getName();
52
53
	public String getRepositoryUrl() {
54
		return repositoryUrl;
55
	}
56
57
	public String getTaskId() {
58
		return taskId;
59
	}
60
61
	public abstract String getUrl();
62
63
	public abstract boolean isLocal();
64
65
	public abstract boolean isPatch();
66
67
}
(-)src/org/eclipse/mylyn/internal/tasks/core/TaskAttachment.java (+109 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.core;
10
11
import java.io.InputStream;
12
13
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.core.runtime.IProgressMonitor;
15
16
/**
17
 * @since 3.0
18
 * @author Steffen Pingel
19
 */
20
public class TaskAttachment extends AbstractTaskAttachment {
21
22
	private String comment;
23
24
	private String contentType;
25
26
	private String description;
27
28
	private boolean patch;
29
30
	private AbstractTaskAttachmentSource source;
31
32
	private String url;
33
34
	public TaskAttachment(String connectorKind, String repositoryUrl, String taskId, String attachmentId) {
35
		super(connectorKind, repositoryUrl, taskId, attachmentId);
36
	}
37
38
	@Override
39
	public InputStream createInputStream(IProgressMonitor monitor) throws CoreException {
40
		return source.createInputStream(monitor);
41
	}
42
43
	public String getComment() {
44
		return comment;
45
	}
46
47
	@Override
48
	public String getContentType() {
49
		return source != null ? source.getContentType() : null;
50
	}
51
52
	@Override
53
	public String getDescription() {
54
		return description;
55
	}
56
57
	@Override
58
	public long getLength() {
59
		return source != null ? source.getLength() : null;
60
	}
61
62
	@Override
63
	public String getName() {
64
		return source != null ? source.getName() : null;
65
	}
66
67
	public AbstractTaskAttachmentSource getSource() {
68
		return source;
69
	}
70
71
	@Override
72
	public String getUrl() {
73
		return url;
74
	}
75
76
	@Override
77
	public boolean isLocal() {
78
		return source != null && source.isLocal();
79
	}
80
81
	@Override
82
	public boolean isPatch() {
83
		return patch;
84
	}
85
86
	public void setComment(String comment) {
87
		this.comment = comment;
88
	}
89
90
	public void setContentType(String contentType) {
91
		this.contentType = contentType;
92
	}
93
94
	public void setDescription(String description) {
95
		this.description = description;
96
	}
97
98
	public void setPatch(boolean patch) {
99
		this.patch = patch;
100
	}
101
102
	public void setSource(AbstractTaskAttachmentSource source) {
103
		this.source = source;
104
	}
105
106
	public void setUrl(String url) {
107
		this.url = url;
108
	}
109
}
(-)src/org/eclipse/mylyn/internal/tasks/core/AbstractTaskAttachmentSource.java (+28 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.core;
10
11
import java.io.InputStream;
12
13
import org.eclipse.core.runtime.CoreException;
14
import org.eclipse.core.runtime.IProgressMonitor;
15
16
public abstract class AbstractTaskAttachmentSource {
17
18
	public abstract InputStream createInputStream(IProgressMonitor monitor) throws CoreException;
19
20
	public abstract boolean isLocal();
21
22
	public abstract long getLength();
23
24
	public abstract String getName();
25
26
	public abstract String getContentType();
27
28
}

Return to bug 222833