Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2008-02-29 15:06:27 -0500
committerspingel2008-02-29 15:06:27 -0500
commite3159a7f92bc681a2b7bbe6a87c6064db4ae571b (patch)
tree07cd896662e340029011850874fe1ef3de7f7fd4
parent19c98c013135e7f96e8aa5b96da1a8995097489c (diff)
downloadorg.eclipse.mylyn.tasks-e3159a7f92bc681a2b7bbe6a87c6064db4ae571b.tar.gz
org.eclipse.mylyn.tasks-e3159a7f92bc681a2b7bbe6a87c6064db4ae571b.tar.xz
org.eclipse.mylyn.tasks-e3159a7f92bc681a2b7bbe6a87c6064db4ae571b.zip
NEW - bug 220862: [patch][v2.3.1] capture screen shot includes screen shot dialogRoot_e_3_4_m_2_x
https://bugs.eclipse.org/bugs/show_bug.cgi?id=220862
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/ScreenshotAttachmentPage.java64
1 files changed, 37 insertions, 27 deletions
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/ScreenshotAttachmentPage.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/ScreenshotAttachmentPage.java
index add552d2f..864d93c4b 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/ScreenshotAttachmentPage.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/ScreenshotAttachmentPage.java
@@ -15,6 +15,9 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.IAction;
@@ -50,6 +53,7 @@ import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.ToolItem;
+import org.eclipse.ui.progress.UIJob;
/**
* A wizard page to create a screenshot from the display.
@@ -400,6 +404,8 @@ public class ScreenshotAttachmentPage extends WizardPage implements IImageCreato
private static final int CURSOR_MARK_TOOL = -1;
+ private static final long CAPTURE_DELAY = 400;
+
private void allocateCursors() {
Display display = getShell().getDisplay();
cursors.put(SWT.CURSOR_ARROW, new Cursor(display, SWT.CURSOR_ARROW));
@@ -446,37 +452,41 @@ public class ScreenshotAttachmentPage extends WizardPage implements IImageCreato
}
private void captureScreenshotContent() {
- Display display = getShell().getDisplay();
- Shell wizardShell = getWizard().getContainer().getShell();
+ final Display display = getShell().getDisplay();
+ final Shell wizardShell = getWizard().getContainer().getShell();
wizardShell.setVisible(false);
- // NOTE: need a wait since the shell can take time to disappear (e.g. fade on Vista)
- try {
- Thread.sleep(400);
- } catch (InterruptedException e) {
- // ignore
- }
-
- disposeImageResources();
- Rectangle displayBounds = display.getBounds();
- originalImage = new Image(display, displayBounds);
- workImage = new Image(display, displayBounds);
-
- GC gc = new GC(display);
- gc.copyArea(originalImage, 0, 0);
- gc.copyArea(workImage, 0, 0);
- gc.dispose();
-
- workImageGC = new GC(workImage);
- workImageGC.setForeground(markColor);
- workImageGC.setLineWidth(4);
- workImageGC.setLineCap(SWT.CAP_ROUND);
+ // this code needs to run asynchronously to allow the workbench to refresh before the screen is captured
+ UIJob job = new UIJob("Capturing Screenshot") {
+
+ @Override
+ public IStatus runInUIThread(IProgressMonitor monitor) {
+ disposeImageResources();
+ Rectangle displayBounds = display.getBounds();
+ originalImage = new Image(display, displayBounds);
+ workImage = new Image(display, displayBounds);
+
+ GC gc = new GC(display);
+ gc.copyArea(originalImage, 0, 0);
+ gc.copyArea(workImage, 0, 0);
+ gc.dispose();
+
+ workImageGC = new GC(workImage);
+ workImageGC.setForeground(markColor);
+ workImageGC.setLineWidth(4);
+ workImageGC.setLineCap(SWT.CAP_ROUND);
+
+ clearSelection();
+ refreshCanvasSize();
- clearSelection();
- refreshCanvasSize();
+ wizardShell.setVisible(true);
+ setPageComplete(true);
- wizardShell.setVisible(true);
- setPageComplete(true);
+ return Status.OK_STATUS;
+ }
+ };
+ // NOTE: need a wait since the shell can take time to disappear (e.g. fade on Vista)
+ job.schedule(CAPTURE_DELAY);
}
/**

Back to the top