Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 90288 Details for
Bug 209897
add a preview page to the Attach Screenshot wizard
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch for preview
clipboard.txt (text/plain), 10.81 KB, created by
Willian Mitsuda
on 2008-02-21 00:38:04 EST
(
hide
)
Description:
Patch for preview
Filename:
MIME Type:
Creator:
Willian Mitsuda
Created:
2008-02-21 00:38:04 EST
Size:
10.81 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.mylyn.tasks.ui >Index: src/org/eclipse/mylyn/internal/tasks/ui/wizards/NewAttachmentPage.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/NewAttachmentPage.java,v >retrieving revision 1.17 >diff -u -r1.17 NewAttachmentPage.java >--- src/org/eclipse/mylyn/internal/tasks/ui/wizards/NewAttachmentPage.java 20 Feb 2008 00:01:57 -0000 1.17 >+++ src/org/eclipse/mylyn/internal/tasks/ui/wizards/NewAttachmentPage.java 21 Feb 2008 05:36:29 -0000 >@@ -239,7 +239,8 @@ > > @Override > public boolean isPageComplete() { >- return !"".equals(filePath.getText().trim()) && (attachmentDesc == null || !"".equals(attachmentDesc.getText().trim())); >+ return !"".equals(filePath.getText().trim()) >+ && (attachmentDesc == null || !"".equals(attachmentDesc.getText().trim())); > } > > public void populateAttachment() { >@@ -253,13 +254,6 @@ > return attachment; > } > >- @Override >- public boolean canFlipToNextPage() { >- if (filePath.getText().equals(InputAttachmentSourcePage.SCREENSHOT_LABEL)) >- return false; >- return isPageComplete(); >- } >- > public void setFilePath(String path) { > filePath.setText(path); > if (path.endsWith(".patch")) { >@@ -298,9 +292,9 @@ > public boolean supportsDescription() { > return supportsDescription; > } >- >+ > public void setSupportsDescription(boolean supportsDescription) { > this.supportsDescription = supportsDescription; > } >- >+ > } >Index: src/org/eclipse/mylyn/internal/tasks/ui/wizards/NewAttachmentWizard.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/NewAttachmentWizard.java,v >retrieving revision 1.38 >diff -u -r1.38 NewAttachmentWizard.java >--- src/org/eclipse/mylyn/internal/tasks/ui/wizards/NewAttachmentWizard.java 5 Feb 2008 04:23:10 -0000 1.38 >+++ src/org/eclipse/mylyn/internal/tasks/ui/wizards/NewAttachmentWizard.java 21 Feb 2008 05:36:29 -0000 >@@ -42,10 +42,6 @@ > import org.eclipse.mylyn.tasks.ui.editors.AbstractRepositoryTaskEditorInput; > import org.eclipse.mylyn.tasks.ui.editors.TaskEditor; > import org.eclipse.mylyn.tasks.ui.editors.TaskEditorInput; >-import org.eclipse.swt.SWT; >-import org.eclipse.swt.graphics.Image; >-import org.eclipse.swt.graphics.ImageData; >-import org.eclipse.swt.graphics.ImageLoader; > import org.eclipse.swt.widgets.Display; > import org.eclipse.ui.PlatformUI; > >@@ -81,7 +77,6 @@ > private boolean screenshotMode; > > public NewAttachmentWizard(TaskRepository repository, AbstractTask task, boolean screenshotMode) { >- super(); > this.task = task; > this.repository = repository; > this.screenshotMode = screenshotMode; >@@ -95,7 +90,12 @@ > } > > inputPage = new InputAttachmentSourcePage(this); >- attachment = new LocalAttachment(); >+ if (screenshotMode) { >+ shotPage = new ScreenshotAttachmentPage(); >+ attachment = new ImageAttachment(shotPage); >+ } else { >+ attachment = new LocalAttachment(); >+ } > attachment.setFilePath(""); > setNeedsProgressMonitor(true); > IDialogSettings workbenchSettings = TasksUiPlugin.getDefault().getDialogSettings(); >@@ -125,6 +125,15 @@ > } > > @Override >+ public void dispose() { >+ // Ensures the temporary screenshot image is deleted >+ if (attachment != null && attachment instanceof ImageAttachment) { >+ ((ImageAttachment) attachment).clearImageFile(); >+ } >+ super.dispose(); >+ } >+ >+ @Override > public boolean performFinish() { > /* TODO jpound - support non-text in clipboard */ > attachPage.populateAttachment(); >@@ -159,19 +168,7 @@ > task.setSynchronizationState(RepositoryTaskSyncState.OUTGOING); > > if (screenshotMode || InputAttachmentSourcePage.SCREENSHOT_LABEL.equals(path)) { >- Image image = shotPage.getScreenshotImage(); >- if (image == null) { >- throw new InvocationTargetException(new CoreException(new RepositoryStatus(IStatus.ERROR, >- TasksUiPlugin.ID_PLUGIN, RepositoryStatus.ERROR_INTERNAL, "Screenshot is empty", >- null))); >- } >- String path = TasksUiPlugin.getDefault().getDefaultDataDirectory(); >- ImageLoader loader = new ImageLoader(); >- loader.data = new ImageData[] { image.getImageData() }; >- String fileName = path + "/" + SCREENSHOT_FILENAME; >- loader.save(fileName, SWT.IMAGE_JPEG); >- attachment.setFile(new File(fileName)); >- attachment.setFilename(SCREENSHOT_FILENAME); >+ ((ImageAttachment) attachment).ensureImageFileWasCreated(); > } else if (InputAttachmentSourcePage.CLIPBOARD_LABEL.equals(path)) { > String contents = inputPage.getClipboardContents(); > if (contents == null) { >@@ -293,7 +290,7 @@ > @Override > public boolean canFinish() { > if (screenshotMode) { >- return shotPage.isPageComplete(); >+ return shotPage.isPageComplete() && attachPage.isPageComplete(); > } else { > return attachPage.isPageComplete(); > } >@@ -303,7 +300,7 @@ > public void addPages() { > super.addPages(); > if (screenshotMode) { >- addPage((shotPage = new ScreenshotAttachmentPage(attachment))); >+ addPage(shotPage); > addPage((attachPage = new NewAttachmentPage(attachment))); > } else { > if ("".equals(attachment.getFilePath())) { >Index: src/org/eclipse/mylyn/internal/tasks/ui/wizards/PreviewAttachmentPage.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/PreviewAttachmentPage.java,v >retrieving revision 1.9 >diff -u -r1.9 PreviewAttachmentPage.java >--- src/org/eclipse/mylyn/internal/tasks/ui/wizards/PreviewAttachmentPage.java 20 Sep 2007 15:21:47 -0000 1.9 >+++ src/org/eclipse/mylyn/internal/tasks/ui/wizards/PreviewAttachmentPage.java 21 Feb 2008 05:36:29 -0000 >@@ -13,10 +13,13 @@ > import java.io.FileNotFoundException; > import java.io.FileReader; > import java.io.IOException; >+import java.lang.reflect.InvocationTargetException; > import java.util.HashMap; > >+import org.eclipse.core.runtime.IProgressMonitor; > import org.eclipse.jface.layout.GridDataFactory; > import org.eclipse.jface.layout.GridLayoutFactory; >+import org.eclipse.jface.operation.IRunnableWithProgress; > import org.eclipse.jface.wizard.WizardPage; > import org.eclipse.mylyn.internal.tasks.core.LocalAttachment; > import org.eclipse.swt.SWT; >@@ -50,7 +53,7 @@ > private static final String TITLE = "Attachment Preview"; > > private static final String DESCRIPTION = "Review the attachment before submitting"; >- >+ > private LocalAttachment attachment; > > private static HashMap<String, String> textTypes; >@@ -93,6 +96,25 @@ > composite.setLayout(new GridLayout()); > setControl(composite); > >+ if (attachment instanceof ImageAttachment) { >+ try { >+ getContainer().run(true, false, new IRunnableWithProgress() { >+ public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { >+ monitor.beginTask("Preparing image for preview...", 1); >+ ((ImageAttachment) attachment).ensureImageFileWasCreated(); >+ monitor.worked(1); >+ monitor.done(); >+ } >+ }); >+ } catch (InvocationTargetException e) { >+ createErrorPreview(composite, "Could not create image for preview"); >+ return; >+ } catch (InterruptedException e) { >+ createErrorPreview(composite, "Could not create image for preview"); >+ return; >+ } >+ } >+ > if (InputAttachmentSourcePage.CLIPBOARD_LABEL.equals(attachment.getFilePath())) { > createTextPreview(composite, ((NewAttachmentWizard) getWizard()).getClipboardContents()); > } else if (PreviewAttachmentPage.isTextAttachment(attachment.getContentType())) { >Index: src/org/eclipse/mylyn/internal/tasks/ui/wizards/ImageAttachment.java >=================================================================== >RCS file: src/org/eclipse/mylyn/internal/tasks/ui/wizards/ImageAttachment.java >diff -N src/org/eclipse/mylyn/internal/tasks/ui/wizards/ImageAttachment.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylyn/internal/tasks/ui/wizards/ImageAttachment.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,90 @@ >+/******************************************************************************* >+ * Copyright (c) 2004, 2007 Mylyn project committers and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ *******************************************************************************/ >+ >+package org.eclipse.mylyn.internal.tasks.ui.wizards; >+ >+import java.io.File; >+ >+import org.eclipse.mylyn.internal.tasks.core.LocalAttachment; >+import org.eclipse.mylyn.tasks.ui.TasksUiPlugin; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.graphics.ImageData; >+import org.eclipse.swt.graphics.ImageLoader; >+ >+/** >+ * Represents a attachment created from a {@link Image}; handles lazy persistence into a {@link File} and image data >+ * change >+ * >+ * @author Willian Mitsuda >+ */ >+public class ImageAttachment extends LocalAttachment { >+ >+ private static final long serialVersionUID = 28264291629999181L; >+ >+ /** >+ * Provides the {@link Image} object that will be converted to desired file format, and then attached >+ */ >+ private IImageCreator imageCreator; >+ >+ public ImageAttachment(IImageCreator imageCreator) { >+ this.imageCreator = imageCreator; >+ } >+ >+ @Override >+ public void setContentType(String contentType) { >+ // Does not apply; actually always save as JPEG >+ // Will be implemented on bug#210179 >+ } >+ >+ @Override >+ public String getContentType() { >+ return "image/jpeg"; >+ } >+ >+ @Override >+ public String getFilename() { >+ return "screenshot.jpg"; >+ } >+ >+ private boolean dirty = true; >+ >+ public void markDirty() { >+ dirty = true; >+ } >+ >+ public void ensureImageFileWasCreated() { >+ if (!dirty) { >+ return; >+ } >+ >+ dirty = false; >+ createContents(); >+ } >+ >+ private void createContents() { >+ Image image = imageCreator.createImage(); >+ try { >+ String path = TasksUiPlugin.getDefault().getDefaultDataDirectory(); >+ ImageLoader loader = new ImageLoader(); >+ loader.data = new ImageData[] { image.getImageData() }; >+ String fileName = path + "/" + getFilename(); >+ loader.save(fileName, SWT.IMAGE_JPEG); >+ setFile(new File(fileName)); >+ setFilePath(fileName); >+ } finally { >+ image.dispose(); >+ } >+ } >+ >+ public void clearImageFile() { >+ String path = TasksUiPlugin.getDefault().getDefaultDataDirectory(); >+ new File(path + "/" + getFilename()).delete(); >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 209897
: 90288