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 74874 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]
region screenshot
160572-region.txt (text/plain), 7.50 KB, created by
Balazs Brinkus
on 2007-07-29 11:28:00 EDT
(
hide
)
Description:
region screenshot
Filename:
MIME Type:
Creator:
Balazs Brinkus
Created:
2007-07-29 11:28:00 EDT
Size:
7.50 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.mylyn.tasks.ui >Index: src/org/eclipse/mylyn/internal/tasks/ui/wizards/ScreenShotAttachmentPage.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/ScreenShotAttachmentPage.java,v >retrieving revision 1.1 >diff -u -r1.1 ScreenShotAttachmentPage.java >--- src/org/eclipse/mylyn/internal/tasks/ui/wizards/ScreenShotAttachmentPage.java 6 Jul 2007 18:50:44 -0000 1.1 >+++ src/org/eclipse/mylyn/internal/tasks/ui/wizards/ScreenShotAttachmentPage.java 29 Jul 2007 14:40:23 -0000 >@@ -12,12 +12,14 @@ > import org.eclipse.jface.wizard.IWizardPage; > import org.eclipse.jface.wizard.WizardPage; > import org.eclipse.mylyn.internal.tasks.core.LocalAttachment; >+import org.eclipse.mylyn.monitor.core.StatusHandler; > 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.Cursor; > import org.eclipse.swt.graphics.GC; > import org.eclipse.swt.graphics.Image; > import org.eclipse.swt.graphics.Point; >@@ -29,6 +31,8 @@ > import org.eclipse.swt.widgets.Canvas; > import org.eclipse.swt.widgets.Composite; > import org.eclipse.swt.widgets.Display; >+import org.eclipse.swt.widgets.Event; >+import org.eclipse.swt.widgets.Listener; > import org.eclipse.swt.widgets.Shell; > > /** >@@ -42,7 +46,9 @@ > > private LocalAttachment attachment; > >- private Button makeShotButton; >+ private Button makeFullShotButton; >+ >+ private Button makeRegionShotButton; > > private Button showShotButton; > >@@ -50,6 +56,10 @@ > > private Canvas canvas; > >+ private Point downPoint; >+ >+ private Point upPoint; >+ > protected ScreenShotAttachmentPage(LocalAttachment attachment) { > super("ScreenShotAttachment"); > setTitle("Create a screenshot"); >@@ -60,19 +70,34 @@ > public void createControl(Composite parent) { > Composite composite = new Composite(parent, SWT.NONE); > GridLayout gridLayout = new GridLayout(); >- gridLayout.numColumns = 2; >+ gridLayout.numColumns = 3; > 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() { >+ makeFullShotButton = new Button(composite, SWT.PUSH); >+ makeFullShotButton.setText("Capture full screen"); >+ makeFullShotButton.addSelectionListener(new SelectionListener() { >+ >+ public void widgetSelected(SelectionEvent e) { >+ storeFullScreenshotContent(); >+ page.setErrorMessage(null); >+ showShotButton.setEnabled(true); >+ } >+ >+ public void widgetDefaultSelected(SelectionEvent e) { >+ } >+ >+ }); >+ >+ makeRegionShotButton = new Button(composite, SWT.PUSH); >+ makeRegionShotButton.setText("Capture region"); >+ makeRegionShotButton.addSelectionListener(new SelectionListener() { > > public void widgetSelected(SelectionEvent e) { >- storeScreenshotContent(); >+ storeRegionScreenshotContent(); > page.setErrorMessage(null); > showShotButton.setEnabled(true); > } >@@ -99,16 +124,19 @@ > canvas.setLayoutData(GridDataFactory.fillDefaults() > .align(SWT.FILL, SWT.FILL) > .grab(true, true) >- .span(2, 1) >+ .span(3, 1) > .create()); > > canvas.addPaintListener(new PaintListener() { > public void paintControl(PaintEvent e) { > if (screenshotImage != null) { >- Rectangle screenBounds = screenshotImage.getBounds(); >+ Rectangle imageBounds = screenshotImage.getBounds(); > Rectangle canvasBounds = canvas.getBounds(); >- e.gc.drawImage(screenshotImage, 0, 0, screenBounds.width, screenBounds.height, 0, 0, >- canvasBounds.width, canvasBounds.height); >+ if ((imageBounds.width > canvasBounds.width) || (imageBounds.height > canvasBounds.height)) >+ e.gc.drawImage(screenshotImage, 0, 0, imageBounds.width, imageBounds.height, 0, 0, >+ canvasBounds.width, canvasBounds.height); >+ else >+ e.gc.drawImage(screenshotImage, 0, 0); > } else { > page.setErrorMessage("Screenshot required"); > showShotButton.setEnabled(false); >@@ -139,7 +167,7 @@ > return isPageComplete(); > } > >- private void storeScreenshotContent() { >+ private void storeFullScreenshotContent() { > > final Display display = Display.getDefault(); > final Shell wizardShell = getWizard().getContainer().getShell(); >@@ -159,6 +187,89 @@ > }); > } > >+ private void storeRegionScreenshotContent() { >+ >+ final Display display = Display.getDefault(); >+ final Rectangle displayBounds = display.getBounds(); >+ final Shell wizardShell = getWizard().getContainer().getShell(); >+ >+ final GC selectionGc = new GC(display); >+ >+ final Listener moveListener = new Listener() { >+ public void handleEvent(Event event) { >+ >+ Point cursorLocation = event.display.getCursorLocation(); >+ final int width = cursorLocation.x - downPoint.x; >+ final int height = cursorLocation.y - downPoint.y; >+ >+ display.getActiveShell().redraw(0, 0, displayBounds.width, displayBounds.height, true); >+ selectionGc.drawRectangle(downPoint.x, downPoint.y, width, height); >+ >+ } >+ }; >+ >+ final Listener upListener = new Listener() { >+ public void handleEvent(Event event) { >+ upPoint = event.display.getCursorLocation(); >+ >+ display.getActiveShell().setCursor(new Cursor(null, SWT.CURSOR_ARROW)); >+ selectionGc.dispose(); >+ display.getActiveShell().redraw(0, 0, displayBounds.width, displayBounds.height, true); >+ >+ display.removeFilter(SWT.MouseMove, moveListener); >+ display.removeFilter(SWT.MouseUp, this); >+ >+ display.asyncExec(new Runnable() { >+ public void run() { >+ try { >+ int width = upPoint.x - downPoint.x; >+ int height = upPoint.y - downPoint.y; >+ >+ Rectangle size = new Rectangle(0, 0, width, height); >+ >+ Image fullscreen = new Image(display, display.getBounds()); >+ screenshotImage = new Image(display, size); >+ >+ GC displayGc = new GC(display); >+ displayGc.copyArea(fullscreen, 0, 0); >+ displayGc.dispose(); >+ >+ GC drawGc = new GC(screenshotImage); >+ drawGc.drawImage(fullscreen, downPoint.x, downPoint.y, width, height, 0, 0, width, height); >+ drawGc.dispose(); >+ >+ canvas.redraw(); >+ wizardShell.setVisible(true); >+ if (screenshotImage != null) >+ setPageComplete(true); >+ >+ } catch (Exception e) { >+ StatusHandler.log(e, "Take screenshot failed!"); >+ wizardShell.setVisible(true); >+ } >+ } >+ }); >+ } >+ }; >+ >+ final Listener downListener = new Listener() { >+ public void handleEvent(Event event) { >+ downPoint = event.display.getCursorLocation(); >+ >+ display.getActiveShell().setCursor(new Cursor(null, SWT.CURSOR_CROSS)); >+ selectionGc.setLineStyle(SWT.LINE_DASH); >+ >+ display.addFilter(SWT.MouseMove, moveListener); >+ display.addFilter(SWT.MouseUp, upListener); >+ display.removeFilter(SWT.MouseDown, this); >+ } >+ }; >+ >+ wizardShell.setVisible(false); >+ display.addFilter(SWT.MouseDown, downListener); >+ >+ } >+ > private void showScreenshotContent() { > Display display = Display.getDefault(); >
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