|
Lines 42-51
Link Here
|
| 42 |
import org.eclipse.mylyn.tasks.ui.editors.AbstractRepositoryTaskEditorInput; |
42 |
import org.eclipse.mylyn.tasks.ui.editors.AbstractRepositoryTaskEditorInput; |
| 43 |
import org.eclipse.mylyn.tasks.ui.editors.TaskEditor; |
43 |
import org.eclipse.mylyn.tasks.ui.editors.TaskEditor; |
| 44 |
import org.eclipse.mylyn.tasks.ui.editors.TaskEditorInput; |
44 |
import org.eclipse.mylyn.tasks.ui.editors.TaskEditorInput; |
| 45 |
import org.eclipse.swt.SWT; |
|
|
| 46 |
import org.eclipse.swt.graphics.Image; |
| 47 |
import org.eclipse.swt.graphics.ImageData; |
| 48 |
import org.eclipse.swt.graphics.ImageLoader; |
| 49 |
import org.eclipse.swt.widgets.Display; |
45 |
import org.eclipse.swt.widgets.Display; |
| 50 |
import org.eclipse.ui.PlatformUI; |
46 |
import org.eclipse.ui.PlatformUI; |
| 51 |
|
47 |
|
|
Lines 81-87
Link Here
|
| 81 |
private boolean screenshotMode; |
77 |
private boolean screenshotMode; |
| 82 |
|
78 |
|
| 83 |
public NewAttachmentWizard(TaskRepository repository, AbstractTask task, boolean screenshotMode) { |
79 |
public NewAttachmentWizard(TaskRepository repository, AbstractTask task, boolean screenshotMode) { |
| 84 |
super(); |
|
|
| 85 |
this.task = task; |
80 |
this.task = task; |
| 86 |
this.repository = repository; |
81 |
this.repository = repository; |
| 87 |
this.screenshotMode = screenshotMode; |
82 |
this.screenshotMode = screenshotMode; |
|
Lines 95-101
Link Here
|
| 95 |
} |
90 |
} |
| 96 |
|
91 |
|
| 97 |
inputPage = new InputAttachmentSourcePage(this); |
92 |
inputPage = new InputAttachmentSourcePage(this); |
| 98 |
attachment = new LocalAttachment(); |
93 |
if (screenshotMode) { |
|
|
94 |
shotPage = new ScreenshotAttachmentPage(); |
| 95 |
attachment = new ImageAttachment(shotPage); |
| 96 |
} else { |
| 97 |
attachment = new LocalAttachment(); |
| 98 |
} |
| 99 |
attachment.setFilePath(""); |
99 |
attachment.setFilePath(""); |
| 100 |
setNeedsProgressMonitor(true); |
100 |
setNeedsProgressMonitor(true); |
| 101 |
IDialogSettings workbenchSettings = TasksUiPlugin.getDefault().getDialogSettings(); |
101 |
IDialogSettings workbenchSettings = TasksUiPlugin.getDefault().getDialogSettings(); |
|
Lines 125-130
Link Here
|
| 125 |
} |
125 |
} |
| 126 |
|
126 |
|
| 127 |
@Override |
127 |
@Override |
|
|
128 |
public void dispose() { |
| 129 |
// Ensures the temporary screenshot image is deleted |
| 130 |
if (attachment != null && attachment instanceof ImageAttachment) { |
| 131 |
((ImageAttachment) attachment).clearImageFile(); |
| 132 |
} |
| 133 |
super.dispose(); |
| 134 |
} |
| 135 |
|
| 136 |
@Override |
| 128 |
public boolean performFinish() { |
137 |
public boolean performFinish() { |
| 129 |
/* TODO jpound - support non-text in clipboard */ |
138 |
/* TODO jpound - support non-text in clipboard */ |
| 130 |
attachPage.populateAttachment(); |
139 |
attachPage.populateAttachment(); |
|
Lines 159-177
Link Here
|
| 159 |
task.setSynchronizationState(RepositoryTaskSyncState.OUTGOING); |
168 |
task.setSynchronizationState(RepositoryTaskSyncState.OUTGOING); |
| 160 |
|
169 |
|
| 161 |
if (screenshotMode || InputAttachmentSourcePage.SCREENSHOT_LABEL.equals(path)) { |
170 |
if (screenshotMode || InputAttachmentSourcePage.SCREENSHOT_LABEL.equals(path)) { |
| 162 |
Image image = shotPage.getScreenshotImage(); |
171 |
((ImageAttachment) attachment).ensureImageFileWasCreated(); |
| 163 |
if (image == null) { |
|
|
| 164 |
throw new InvocationTargetException(new CoreException(new RepositoryStatus(IStatus.ERROR, |
| 165 |
TasksUiPlugin.ID_PLUGIN, RepositoryStatus.ERROR_INTERNAL, "Screenshot is empty", |
| 166 |
null))); |
| 167 |
} |
| 168 |
String path = TasksUiPlugin.getDefault().getDefaultDataDirectory(); |
| 169 |
ImageLoader loader = new ImageLoader(); |
| 170 |
loader.data = new ImageData[] { image.getImageData() }; |
| 171 |
String fileName = path + "/" + SCREENSHOT_FILENAME; |
| 172 |
loader.save(fileName, SWT.IMAGE_JPEG); |
| 173 |
attachment.setFile(new File(fileName)); |
| 174 |
attachment.setFilename(SCREENSHOT_FILENAME); |
| 175 |
} else if (InputAttachmentSourcePage.CLIPBOARD_LABEL.equals(path)) { |
172 |
} else if (InputAttachmentSourcePage.CLIPBOARD_LABEL.equals(path)) { |
| 176 |
String contents = inputPage.getClipboardContents(); |
173 |
String contents = inputPage.getClipboardContents(); |
| 177 |
if (contents == null) { |
174 |
if (contents == null) { |
|
Lines 293-299
Link Here
|
| 293 |
@Override |
290 |
@Override |
| 294 |
public boolean canFinish() { |
291 |
public boolean canFinish() { |
| 295 |
if (screenshotMode) { |
292 |
if (screenshotMode) { |
| 296 |
return shotPage.isPageComplete(); |
293 |
return shotPage.isPageComplete() && attachPage.isPageComplete(); |
| 297 |
} else { |
294 |
} else { |
| 298 |
return attachPage.isPageComplete(); |
295 |
return attachPage.isPageComplete(); |
| 299 |
} |
296 |
} |
|
Lines 303-309
Link Here
|
| 303 |
public void addPages() { |
300 |
public void addPages() { |
| 304 |
super.addPages(); |
301 |
super.addPages(); |
| 305 |
if (screenshotMode) { |
302 |
if (screenshotMode) { |
| 306 |
addPage((shotPage = new ScreenshotAttachmentPage(attachment))); |
303 |
addPage(shotPage); |
| 307 |
addPage((attachPage = new NewAttachmentPage(attachment))); |
304 |
addPage((attachPage = new NewAttachmentPage(attachment))); |
| 308 |
} else { |
305 |
} else { |
| 309 |
if ("".equals(attachment.getFilePath())) { |
306 |
if ("".equals(attachment.getFilePath())) { |