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 72353 Details for
Bug 160572
[new eux] add ability to attach images to tasks
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]
screenshot page
160572-screenshot.txt (text/plain), 17.21 KB, created by
Balazs Brinkus
on 2007-06-25 09:44:59 EDT
(
hide
)
Description:
screenshot page
Filename:
MIME Type:
Creator:
Balazs Brinkus
Created:
2007-06-25 09:44:59 EDT
Size:
17.21 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.mylyn.tasks.ui >Index: src/org/eclipse/mylyn/internal/tasks/ui/wizards/InputAttachmentSourcePage.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/InputAttachmentSourcePage.java,v >retrieving revision 1.7 >diff -u -r1.7 InputAttachmentSourcePage.java >--- src/org/eclipse/mylyn/internal/tasks/ui/wizards/InputAttachmentSourcePage.java 21 Jun 2007 20:43:11 -0000 1.7 >+++ src/org/eclipse/mylyn/internal/tasks/ui/wizards/InputAttachmentSourcePage.java 25 Jun 2007 13:39:37 -0000 >@@ -78,6 +78,8 @@ > > public static final String CLIPBOARD_LABEL = "<Clipboard>"; > >+ public static final String SCREENSHOT_LABEL = "<Screenshot>"; >+ > // input constants > protected final static int CLIPBOARD = 1; > >@@ -85,6 +87,8 @@ > > protected final static int WORKSPACE = 3; > >+ protected final static int SCREENSHOT = 4; >+ > static final char SEPARATOR = System.getProperty("file.separator").charAt(0); //$NON-NLS-1$ > > private boolean showError = false; >@@ -94,6 +98,8 @@ > // SWT widgets > private Button useClipboardButton; > >+ private Button useScreenshotButton; >+ > private Combo fileNameField; > > private Button fileBrowseButton; >@@ -183,7 +189,10 @@ > > @Override > public IWizardPage getNextPage() { >- return wizard.getNextPage(this); >+ if (getInputMethod() == SCREENSHOT) { >+ return wizard.getPage("ScreenShotAttachment"); >+ } else >+ return wizard.getNextPage(this); > } > > /* >@@ -224,6 +233,13 @@ > useClipboardButton.setSelection(initUseClipboard); > > // 2nd row >+ gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); >+ gd.horizontalSpan = 3; >+ useScreenshotButton = new Button(composite, SWT.RADIO); >+ useScreenshotButton.setText("Screenshot"); >+ useScreenshotButton.setLayoutData(gd); >+ >+ // 3rd row > useFileButton = new Button(composite, SWT.RADIO); > useFileButton.setText("File"); > >@@ -241,7 +257,7 @@ > data.widthHint = Math.max(widthHint, minSize.x); > fileBrowseButton.setLayoutData(data); > >- // 3rd row >+ // 4th row > useWorkspaceButton = new Button(composite, SWT.RADIO); > useWorkspaceButton.setText("Workspace"); > gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); >@@ -266,6 +282,21 @@ > } > }); > >+ useScreenshotButton.addSelectionListener(new SelectionAdapter() { >+ @Override >+ public void widgetSelected(SelectionEvent e) { >+ if (!useScreenshotButton.getSelection()) >+ return; >+ >+ clearErrorMessage(); >+ showError = true; >+ int state = getInputMethod(); >+ setEnableAttachmentFile(state == FILE); >+ setEnableWorkspaceAttachment(state == WORKSPACE); >+ updateWidgetEnablements(); >+ } >+ }); >+ > useFileButton.addSelectionListener(new SelectionAdapter() { > @Override > public void widgetSelected(SelectionEvent e) { >@@ -405,6 +436,8 @@ > error = "Clipboard does not contain text"; > } else > error = "Cannot retrieve clipboard contents"; >+ } else if (inputMethod == SCREENSHOT) { >+ attachmentFound = true; > } else if (inputMethod == FILE) { > String path = fileNameField.getText(); > if (path != null && path.length() > 0) { >@@ -442,8 +475,8 @@ > } > > /** >- * Sets the source name of the import to be the supplied path. Adds the name >- * of the path to the list of items in the source combo and selects it. >+ * Sets the source name of the import to be the supplied path. Adds the name of the path to the list of items in the >+ * source combo and selects it. > * > * @param path > * the path to be added >@@ -498,6 +531,9 @@ > } > return FILE; > } >+ if (useScreenshotButton.getSelection()) { >+ return SCREENSHOT; >+ } > if (useClipboardButton.getSelection()) { > return CLIPBOARD; > } >@@ -518,6 +554,8 @@ > switch (getInputMethod()) { > case CLIPBOARD: > return CLIPBOARD_LABEL; >+ case SCREENSHOT: >+ return SCREENSHOT_LABEL; > case WORKSPACE: > IResource[] resources = getResources(treeViewer.getSelection()); > if (resources.length > 0 && resources[0].getRawLocation() != null) { >@@ -606,4 +644,5 @@ > } > initUseClipboard = b; > } >+ > } >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.31 >diff -u -r1.31 NewAttachmentWizard.java >--- src/org/eclipse/mylyn/internal/tasks/ui/wizards/NewAttachmentWizard.java 23 Jun 2007 03:23:01 -0000 1.31 >+++ src/org/eclipse/mylyn/internal/tasks/ui/wizards/NewAttachmentWizard.java 25 Jun 2007 13:39:37 -0000 >@@ -44,6 +44,10 @@ > 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; > >@@ -58,6 +62,8 @@ > > protected static final String CLIPBOARD_FILENAME = "clipboard.txt"; > >+ protected static final String SCREENSHOT_FILENAME = "screenshot.jpg"; >+ > private LocalAttachment attachment; > > private InputAttachmentSourcePage inputPage; >@@ -66,6 +72,8 @@ > > private NewAttachmentWizardDialog dialog; > >+ private ScreenShotAttachmentPage shotPage; >+ > private boolean hasNewDialogSettings; > > private TaskRepository repository; >@@ -137,22 +145,38 @@ > } > monitor.beginTask("Attaching file...", 2); > task.setSubmitting(true); >- task.setSynchronizationState(RepositoryTaskSyncState.OUTGOING); >+ task.setSynchronizationState(RepositoryTaskSyncState.OUTGOING); > > if (InputAttachmentSourcePage.CLIPBOARD_LABEL.equals(path)) { > String contents = inputPage.getClipboardContents(); > if (contents == null) { >- throw new InvocationTargetException(new CoreException(new RepositoryStatus(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, RepositoryStatus.ERROR_INTERNAL, "Clipboard is empty", null))); >+ throw new InvocationTargetException(new CoreException(new RepositoryStatus(IStatus.ERROR, >+ TasksUiPlugin.ID_PLUGIN, RepositoryStatus.ERROR_INTERNAL, "Clipboard is empty", >+ null))); > } > attachment.setContent(contents.getBytes()); > attachment.setFilename(CLIPBOARD_FILENAME); >+ } else if (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); > } else { > File file = new File(path); > attachment.setFile(file); > attachment.setFilename(file.getName()); > } >- >- attachmentHandler.uploadAttachment(repository, task, attachment, attachment.getComment(), >+ >+ attachmentHandler.uploadAttachment(repository, task, attachment, attachment.getComment(), > new SubProgressMonitor(monitor, 1)); > > if (monitor.isCanceled()) { >@@ -160,7 +184,8 @@ > } > > if (attachContext && connector.getAttachmentHandler() != null) { >- connector.getAttachmentHandler().attachContext(repository, task, "", new SubProgressMonitor(monitor, 1)); >+ connector.getAttachmentHandler().attachContext(repository, task, "", >+ new SubProgressMonitor(monitor, 1)); > } > } catch (CoreException e) { > throw new InvocationTargetException(e); >@@ -267,6 +292,7 @@ > addPage(inputPage); > } > addPage((attachPage = new NewAttachmentPage(attachment))); >+ addPage((shotPage = new ScreenShotAttachmentPage(attachment))); > } > > public LocalAttachment getAttachment() { >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.11 >diff -u -r1.11 NewAttachmentPage.java >--- src/org/eclipse/mylyn/internal/tasks/ui/wizards/NewAttachmentPage.java 23 Jun 2007 00:37:52 -0000 1.11 >+++ src/org/eclipse/mylyn/internal/tasks/ui/wizards/NewAttachmentPage.java 25 Jun 2007 13:39:37 -0000 >@@ -54,6 +54,8 @@ > > private Button attachContextButton; > >+ private Combo contentTypeList; >+ > private static List<String> contentTypes; > > private static Map<String, String> extensions2Types; >@@ -134,7 +136,7 @@ > > new Label(composite, SWT.NONE).setText("Content Type");// .setBackground(parent.getBackground()); > >- final Combo contentTypeList = new Combo(composite, SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY); >+ contentTypeList = new Combo(composite, SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY); > contentTypeList.setLayoutData(new GridData(SWT.DEFAULT, SWT.DEFAULT, false, false, 2, 1)); > final HashMap<String, Integer> contentTypeIndices = new HashMap<String, Integer>(); > Iterator<String> iter = contentTypes.iterator(); >@@ -247,6 +249,8 @@ > > @Override > public boolean canFlipToNextPage() { >+ if (filePath.getText().equals(InputAttachmentSourcePage.SCREENSHOT_LABEL)) >+ return false; > return isPageComplete(); > } > >@@ -271,4 +275,18 @@ > public boolean getAttachContext() { > return attachContextButton.getSelection(); > } >+ >+ public void setContentType() { >+ String type = attachment.getContentType(); >+ String[] typeList = contentTypeList.getItems(); >+ for (int i = 0; i < typeList.length; i++) { >+ if (typeList[i].equals(type)) { >+ contentTypeList.select(i); >+ contentTypeList.setEnabled(false); >+ isPatchButton.setEnabled(false); >+ return; >+ } >+ } >+ } >+ > } >\ No newline at end of file >Index: src/org/eclipse/mylyn/internal/tasks/ui/wizards/ScreenShotAttachmentPage.java >=================================================================== >RCS file: src/org/eclipse/mylyn/internal/tasks/ui/wizards/ScreenShotAttachmentPage.java >diff -N src/org/eclipse/mylyn/internal/tasks/ui/wizards/ScreenShotAttachmentPage.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylyn/internal/tasks/ui/wizards/ScreenShotAttachmentPage.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,199 @@ >+/******************************************************************************* >+ * Copyright (c) 2004 - 2007 University Of British Columbia 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 >+ * >+ * Contributors: >+ * University Of British Columbia - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.mylyn.internal.tasks.ui.wizards; >+ >+import org.eclipse.jface.layout.GridDataFactory; >+import org.eclipse.jface.wizard.IWizardPage; >+import org.eclipse.jface.wizard.WizardPage; >+import org.eclipse.mylyn.internal.tasks.core.LocalAttachment; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.custom.ScrolledComposite; >+import org.eclipse.swt.events.PaintEvent; >+import org.eclipse.swt.events.PaintListener; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.events.SelectionListener; >+import org.eclipse.swt.graphics.GC; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.graphics.Point; >+import org.eclipse.swt.graphics.Rectangle; >+import org.eclipse.swt.layout.FillLayout; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Button; >+import org.eclipse.swt.widgets.Canvas; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Display; >+import org.eclipse.swt.widgets.Shell; >+ >+/** >+ * A wizard page to create a screenshot from the display. >+ * >+ * @author Balazs Brinkus (bug 160572) >+ */ >+public class ScreenShotAttachmentPage extends WizardPage { >+ >+ private ScreenShotAttachmentPage page; >+ >+ private LocalAttachment attachment; >+ >+ private Button makeShotButton; >+ >+ private Button showShotButton; >+ >+ private Image screenshotImage; >+ >+ private Canvas canvas; >+ >+ protected ScreenShotAttachmentPage(LocalAttachment attachment) { >+ super("ScreenShotAttachment"); >+ setTitle("Create a screenshot"); >+ this.attachment = attachment; >+ this.page = this; >+ } >+ >+ public void createControl(Composite parent) { >+ Composite composite = new Composite(parent, SWT.NONE); >+ GridLayout gridLayout = new GridLayout(); >+ gridLayout.numColumns = 2; >+ composite.setLayout(gridLayout); >+ setControl(composite); >+ >+ composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); >+ composite.setLayout(new GridLayout(3, false)); >+ >+ makeShotButton = new Button(composite, SWT.PUSH); >+ makeShotButton.setText("Take a screenshot"); >+ makeShotButton.addSelectionListener(new SelectionListener() { >+ >+ public void widgetSelected(SelectionEvent e) { >+ storeScreenshotContent(); >+ page.setErrorMessage(null); >+ showShotButton.setEnabled(true); >+ } >+ >+ public void widgetDefaultSelected(SelectionEvent e) { >+ } >+ >+ }); >+ >+ showShotButton = new Button(composite, SWT.PUSH); >+ showShotButton.setText("Show the screenshot"); >+ showShotButton.addSelectionListener(new SelectionListener() { >+ >+ public void widgetSelected(SelectionEvent e) { >+ showScreenshotContent(); >+ } >+ >+ public void widgetDefaultSelected(SelectionEvent e) { >+ } >+ >+ }); >+ >+ canvas = new Canvas(composite, SWT.BORDER); >+ canvas.setLayoutData(GridDataFactory.fillDefaults() >+ .align(SWT.FILL, SWT.FILL) >+ .grab(true, true) >+ .span(2, 1) >+ .create()); >+ >+ canvas.addPaintListener(new PaintListener() { >+ public void paintControl(PaintEvent e) { >+ if (screenshotImage != null) { >+ Rectangle screenBounds = screenshotImage.getBounds(); >+ Rectangle canvasBounds = canvas.getBounds(); >+ e.gc.drawImage(screenshotImage, 0, 0, screenBounds.width, screenBounds.height, 0, 0, >+ canvasBounds.width, canvasBounds.height); >+ } else { >+ page.setErrorMessage("Screenshot required"); >+ showShotButton.setEnabled(false); >+ } >+ } >+ }); >+ >+ } >+ >+ @Override >+ public boolean isPageComplete() { >+ if (screenshotImage == null) >+ return false; >+ return true; >+ } >+ >+ @Override >+ public IWizardPage getNextPage() { >+ NewAttachmentPage page = (NewAttachmentPage) getWizard().getPage("AttachmentDetails"); >+ attachment.setContentType("image/jpeg"); >+ page.setFilePath(InputAttachmentSourcePage.SCREENSHOT_LABEL); >+ page.setContentType(); >+ return page; >+ } >+ >+ @Override >+ public boolean canFlipToNextPage() { >+ return isPageComplete(); >+ } >+ >+ private void storeScreenshotContent() { >+ >+ final Display display = Display.getDefault(); >+ final Shell wizardShell = getWizard().getContainer().getShell(); >+ wizardShell.setVisible(false); >+ >+ display.asyncExec(new Runnable() { >+ public void run() { >+ GC gc = new GC(display); >+ screenshotImage = new Image(display, display.getBounds()); >+ gc.copyArea(screenshotImage, 0, 0); >+ gc.dispose(); >+ canvas.redraw(); >+ wizardShell.setVisible(true); >+ if (screenshotImage != null) >+ setPageComplete(true); >+ } >+ }); >+ } >+ >+ private void showScreenshotContent() { >+ Display display = Display.getDefault(); >+ >+ Shell popup = new Shell(display.getActiveShell(), SWT.SHELL_TRIM); >+ popup.setLayout(new FillLayout()); >+ popup.setText("Screenshot Image"); >+ >+ Rectangle displayBounds = Display.getDefault().getBounds(); >+ Point dialogSize = new Point(0, 0); >+ dialogSize.x = displayBounds.width / 2; >+ dialogSize.y = displayBounds.height / 2; >+ Point dialoglocation = new Point(0, 0); >+ dialoglocation.x = displayBounds.x + displayBounds.width / 2 - dialogSize.x / 2; >+ dialoglocation.y = displayBounds.y + displayBounds.height / 2 - dialogSize.y / 2; >+ popup.setSize(dialogSize); >+ popup.setLocation(dialoglocation); >+ >+ ScrolledComposite sc = new ScrolledComposite(popup, SWT.V_SCROLL | SWT.H_SCROLL); >+ Canvas canvas = new Canvas(sc, SWT.NONE); >+ sc.setContent(canvas); >+ canvas.setBounds(display.getBounds()); >+ canvas.addPaintListener(new PaintListener() { >+ public void paintControl(PaintEvent e) { >+ if (screenshotImage != null) >+ e.gc.drawImage(screenshotImage, 0, 0); >+ } >+ }); >+ popup.open(); >+ } >+ >+ public Image getScreenshotImage() { >+ return screenshotImage; >+ } >+ >+}
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 160572
: 72353 |
72354
|
72683
|
74874
|
75088
|
75089
|
75449
|
75450
|
75466
|
75467
|
75931
|
76061
|
76356
|
76357
|
77091