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 75088 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]
crop picture
160572-crop.txt (text/plain), 9.50 KB, created by
Balazs Brinkus
on 2007-07-31 20:55:04 EDT
(
hide
)
Description:
crop picture
Filename:
MIME Type:
Creator:
Balazs Brinkus
Created:
2007-07-31 20:55:04 EDT
Size:
9.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 31 Jul 2007 23:17:14 -0000 >@@ -14,10 +14,14 @@ > import org.eclipse.mylyn.internal.tasks.core.LocalAttachment; > import org.eclipse.swt.SWT; > import org.eclipse.swt.custom.ScrolledComposite; >+import org.eclipse.swt.events.MouseEvent; >+import org.eclipse.swt.events.MouseListener; >+import org.eclipse.swt.events.MouseMoveListener; > 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; >@@ -44,6 +48,8 @@ > > private Button makeShotButton; > >+ private Button cropShotButton; >+ > private Button showShotButton; > > private Image screenshotImage; >@@ -59,21 +65,18 @@ > > 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.setText("Capture full screen"); > makeShotButton.addSelectionListener(new SelectionListener() { > > public void widgetSelected(SelectionEvent e) { > storeScreenshotContent(); > page.setErrorMessage(null); >+ cropShotButton.setEnabled(true); > showShotButton.setEnabled(true); > } > >@@ -82,6 +85,19 @@ > > }); > >+ cropShotButton = new Button(composite, SWT.PUSH); >+ cropShotButton.setText("Crop a region"); >+ cropShotButton.addSelectionListener(new SelectionListener() { >+ >+ public void widgetSelected(SelectionEvent e) { >+ cropScreenshotContent(); >+ } >+ >+ public void widgetDefaultSelected(SelectionEvent e) { >+ } >+ >+ }); >+ > showShotButton = new Button(composite, SWT.PUSH); > showShotButton.setText("Show the screenshot"); > showShotButton.addSelectionListener(new SelectionListener() { >@@ -99,18 +115,22 @@ > 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"); >+ cropShotButton.setEnabled(false); > showShotButton.setEnabled(false); > } > } >@@ -148,8 +168,10 @@ > display.asyncExec(new Runnable() { > public void run() { > GC gc = new GC(display); >- screenshotImage = new Image(display, display.getBounds()); >+ Rectangle displayBounds = display.getBounds(); >+ screenshotImage = new Image(display, displayBounds); > gc.copyArea(screenshotImage, 0, 0); >+ gc.drawRectangle(0, 0, displayBounds.width - 1, displayBounds.height - 1); > gc.dispose(); > canvas.redraw(); > wizardShell.setVisible(true); >@@ -159,6 +181,160 @@ > }); > } > >+ private void cropScreenshotContent() { >+ >+ final Point downPoint = new Point(-1, -1); >+ >+ final Rectangle newImageBounds = new Rectangle(-1, -1, -1, -1); >+ >+ final Display display = Display.getDefault(); >+ final Rectangle displayBounds = display.getBounds(); >+ >+ final Shell popup = new Shell(display.getActiveShell(), SWT.SHELL_TRIM); >+ popup.setLayout(new GridLayout()); >+ popup.setText("Crop a region of the screenshot"); >+ >+ Point dialogSize = new Point(0, 0); >+ dialogSize.x = displayBounds.width - 100; >+ dialogSize.y = displayBounds.height - 100; >+ 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); >+ >+ final Rectangle originalBounds = screenshotImage.getBounds(); >+ final Image bufferedImage = new Image(display, originalBounds); >+ GC gc = new GC(bufferedImage); >+ gc.setBackground(popup.getBackground()); >+ gc.fillRectangle(originalBounds); >+ gc.drawImage(screenshotImage, 0, 0); >+ gc.dispose(); >+ >+ Composite bc = new Composite(popup, SWT.NONE); >+ bc.setLayout(new GridLayout(2, false)); >+ >+ final Button saveButton = new Button(bc, SWT.PUSH); >+ saveButton.setText("Save"); >+ saveButton.addSelectionListener(new SelectionListener() { >+ public void widgetSelected(SelectionEvent e) { >+ if (newImageBounds.x != -1 && newImageBounds.y != -1) { >+ screenshotImage = new Image(display, newImageBounds); >+ GC drawGc = new GC(screenshotImage); >+ drawGc.drawImage(bufferedImage, newImageBounds.x, newImageBounds.y, newImageBounds.width, >+ newImageBounds.height, 0, 0, newImageBounds.width, newImageBounds.height); >+ drawGc.drawRectangle(0, 0, newImageBounds.width - 1, newImageBounds.height - 1); >+ drawGc.dispose(); >+ canvas.redraw(); >+ popup.close(); >+ } >+ } >+ >+ public void widgetDefaultSelected(SelectionEvent e) { >+ // ignore >+ } >+ }); >+ saveButton.setEnabled(false); >+ >+ final Button cancelButton = new Button(bc, SWT.PUSH); >+ cancelButton.setText("Cancel"); >+ cancelButton.addSelectionListener(new SelectionListener() { >+ public void widgetSelected(SelectionEvent e) { >+ popup.close(); >+ } >+ >+ public void widgetDefaultSelected(SelectionEvent e) { >+ // ignore >+ } >+ }); >+ >+ final ScrolledComposite sc = new ScrolledComposite(popup, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER); >+ sc.setLayoutData(GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).create()); >+ final Canvas scCanvas = new Canvas(sc, SWT.DOUBLE_BUFFERED | SWT.NONE); >+ scCanvas.setBounds(originalBounds); >+ scCanvas.addPaintListener(new PaintListener() { >+ public void paintControl(PaintEvent e) { >+ if (screenshotImage != null) >+ e.gc.drawImage(bufferedImage, 0, 0); >+ } >+ }); >+ sc.setContent(scCanvas); >+ >+ final GC selectionGc = new GC(scCanvas); >+ >+ final MouseMoveListener mouseMoveListener = new MouseMoveListener() { >+ public void mouseMove(MouseEvent e) { >+ if (downPoint.x != -1 && downPoint.y != -1) { >+ int width = e.x - downPoint.x; >+ int height = e.y - downPoint.y; >+ scCanvas.redraw(); >+ selectionGc.drawRectangle(downPoint.x, downPoint.y, width, height); >+ } >+ } >+ }; >+ >+ final MouseListener mouseListener = new MouseListener() { >+ public void mouseUp(MouseEvent e) { >+ if (downPoint.x != -1 && downPoint.y != -1) { >+ >+ int width; >+ if (e.x > originalBounds.width) >+ width = originalBounds.width - downPoint.x; >+ else if (e.x < 0) { >+ width = downPoint.x; >+ downPoint.x = 0; >+ } >+ else >+ width = e.x - downPoint.x; >+ >+ int height; >+ if (e.y > originalBounds.height) >+ height = originalBounds.height - downPoint.y; >+ else if (e.y < 0) { >+ height = downPoint.y; >+ downPoint.y = 0; >+ } else >+ height = e.y - downPoint.y; >+ >+ display.getActiveShell().setCursor(new Cursor(null, SWT.CURSOR_ARROW)); >+ >+ selectionGc.drawRectangle(downPoint.x, downPoint.y, width, height); >+ >+ newImageBounds.x = downPoint.x; >+ newImageBounds.y = downPoint.y; >+ newImageBounds.width = width; >+ newImageBounds.height = height; >+ >+ sc.removeMouseMoveListener(mouseMoveListener); >+ sc.removeMouseListener(this); >+ downPoint.x = -1; >+ downPoint.y = -1; >+ >+ saveButton.setEnabled(true); >+ } >+ } >+ >+ public void mouseDown(MouseEvent e) { >+ if (downPoint.x == -1 && downPoint.y == -1) { >+ display.getActiveShell().setCursor(new Cursor(null, SWT.CURSOR_CROSS)); >+ downPoint.x = e.x; >+ downPoint.y = e.y; >+ selectionGc.setLineStyle(SWT.LINE_DASH); >+ scCanvas.addMouseMoveListener(mouseMoveListener); >+ } >+ } >+ >+ public void mouseDoubleClick(MouseEvent e) { >+ // ignore >+ } >+ }; >+ >+ scCanvas.addMouseListener(mouseListener); >+ >+ popup.open(); >+ >+ } >+ > 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