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 126835 Details for
Bug 266123
improve the capture method and the draw tool
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]
capturedialog.patch
capturedialog.patch (text/plain), 19.28 KB, created by
Hiroyuki
on 2009-02-26 05:59:58 EST
(
hide
)
Description:
capturedialog.patch
Filename:
MIME Type:
Creator:
Hiroyuki
Created:
2009-02-26 05:59:58 EST
Size:
19.28 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.mylyn.commons.ui >Index: src/org/eclipse/mylyn/internal/provisional/commons/ui/ScreenshotCreationPage.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.commons.ui/src/org/eclipse/mylyn/internal/provisional/commons/ui/ScreenshotCreationPage.java,v >retrieving revision 1.8 >diff -u -r1.8 ScreenshotCreationPage.java >--- src/org/eclipse/mylyn/internal/provisional/commons/ui/ScreenshotCreationPage.java 7 Dec 2008 05:33:08 -0000 1.8 >+++ src/org/eclipse/mylyn/internal/provisional/commons/ui/ScreenshotCreationPage.java 26 Feb 2009 10:58:33 -0000 >@@ -71,7 +71,7 @@ > */ > public class ScreenshotCreationPage extends WizardPage implements IImageCreator { > >- private IAction captureAction; >+ private SelectCaptureAction captureAction; > > private IAction fitAction; > >@@ -79,6 +79,8 @@ > > private IAction markAction; > >+ private SelectDrawToolAction toolAction; >+ > private IAction colorAction; > > private Image colorIcon; >@@ -99,6 +101,8 @@ > */ > private Image workImage; > >+ private Image previousImage; >+ > /** > * Used to draw into {@link #workImage} > */ >@@ -155,6 +159,8 @@ > */ > private EditorAction currentAction = EditorAction.CROPPING; > >+ private boolean isFirstCapture = true; >+ > public ScreenshotCreationPage() { > super("ScreenShotAttachment"); //$NON-NLS-1$ > setTitle(Messages.ScreenshotCreationPage_CAPTURE_SCRRENSHOT); >@@ -173,13 +179,17 @@ > > // TODO: need disabled versions of all toolbar icons > ToolBarManager tbm = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL | SWT.RIGHT); >- captureAction = new Action(Messages.ScreenshotCreationPage_Capture_Desktop_C, IAction.AS_PUSH_BUTTON) { > >- private boolean isFirstCapture = true; >+ captureAction = new SelectCaptureAction(getShell(), Messages.ScreenshotCreationPage_Capture_Desktop_C) { > > @Override > public void run() { >- captureScreenshotContent(); >+ if (captureAction.getKind() == SelectCaptureAction.Selection.CAPTURE) { >+ captureScreenshotContent(); >+ } else { >+ captureScreenshotContent(captureAction.getScreenshotImage()); >+ } >+ captureAction.resetKind(); > setErrorMessage(null); > if (isFirstCapture) { > isFirstCapture = false; >@@ -246,6 +256,7 @@ > currentAction = EditorAction.CROPPING; > cropAction.setChecked(true); > markAction.setChecked(false); >+ toolAction.setEnabled(false); > colorAction.setEnabled(false); > canvas.redraw(); > } >@@ -260,6 +271,7 @@ > currentAction = EditorAction.MARKING; > cropAction.setChecked(false); > markAction.setChecked(true); >+ toolAction.setEnabled(true); > colorAction.setEnabled(true); > canvas.redraw(); > } >@@ -269,6 +281,9 @@ > // markAction.setDisabledImageDescriptor(ImageDescriptor.createFromFile(getClass(), "mark_disabled.gif")); > markAction.setEnabled(false); > >+ toolAction = new SelectDrawToolAction(); >+ toolAction.setEnabled(false); >+ > colorAction = new Action("", IAction.AS_DROP_DOWN_MENU) { //$NON-NLS-1$ > @Override > public void runWithEvent(final Event e) { >@@ -316,6 +331,7 @@ > tbm.add(new Separator()); > tbm.add(createAndConfigureCI(cropAction)); > tbm.add(createAndConfigureCI(markAction)); >+ tbm.add(createAndConfigureCI(toolAction)); > tbm.add(createAndConfigureCI(colorAction)); > tbm.add(new Separator()); > tbm.add(createAndConfigureCI(clearAction)); >@@ -455,6 +471,28 @@ > return isPageComplete(); > } > >+ private void captureScreenshotContent(Image image) { >+ final Display display = getShell().getDisplay(); >+ disposeImageResources(); >+ originalImage = image; >+ Rectangle displayBounds = originalImage.getBounds(); >+ workImage = new Image(display, displayBounds.width, displayBounds.height); >+ GC gc = new GC(workImage); >+ gc.drawImage(originalImage, 0, 0); >+ gc.dispose(); >+ >+ workImageGC = new GC(workImage); >+ workImageGC.setForeground(markColor); >+ workImageGC.setLineWidth(4); >+ workImageGC.setLineCap(SWT.CAP_ROUND); >+ >+ scrolledComposite.setEnabled(true); >+ clearSelection(); >+ refreshCanvasSize(); >+ >+ setPageComplete(true); >+ } >+ > private void captureScreenshotContent() { > final Display display = getShell().getDisplay(); > final Shell wizardShell = getWizard().getContainer().getShell(); >@@ -701,6 +739,11 @@ > } else if (currentAction == EditorAction.MARKING) { > startPoint = null; > setImageDirty(true); >+ >+ if (toolAction.getKind() != SelectDrawToolAction.DrawKind.FREE) { >+ previousImage.dispose(); >+ previousImage = null; >+ } > } > } > >@@ -713,6 +756,14 @@ > int scaledY = (int) (e.y / scaleFactor); > > if (currentAction == EditorAction.MARKING) { >+ if (toolAction.getKind() != SelectDrawToolAction.DrawKind.FREE) { >+ Display display = getShell().getDisplay(); >+ previousImage = new Image(display, workImage.getBounds()); >+ GC gc = new GC(previousImage); >+ gc.drawImage(workImage, 0, 0); >+ gc.dispose(); >+ } >+ > startPoint = new Point(scaledX, scaledY); > drawMarkLine(scaledX, scaledY); > canvas.setCursor(cursors.get(CURSOR_MARK_TOOL)); >@@ -850,14 +901,29 @@ > } > > /** >- * Connects the previous mark point to the new reference point, by drawing a new line >+ * Connects the previous mark point to the new reference point, by drawing a new line, rectangle or oval > */ > private void drawMarkLine(int x, int y) { > if (startPoint != null) { > clearAction.setEnabled(true); >- workImageGC.drawLine(startPoint.x, startPoint.y, x, y); >- startPoint.x = x; >- startPoint.y = y; >+ if (toolAction.getKind() == SelectDrawToolAction.DrawKind.FREE) { >+ workImageGC.drawLine(startPoint.x, startPoint.y, x, y); >+ startPoint.x = x; >+ startPoint.y = y; >+ } else { >+ workImageGC.drawImage(previousImage, 0, 0); >+ if (startPoint.x == x && startPoint.y == y) { >+ workImageGC.drawLine(startPoint.x, startPoint.y, x, y); >+ } else { >+ if (toolAction.getKind() == SelectDrawToolAction.DrawKind.LINE) { >+ workImageGC.drawLine(startPoint.x, startPoint.y, x, y); >+ } else if (toolAction.getKind() == SelectDrawToolAction.DrawKind.BOX) { >+ workImageGC.drawRectangle(startPoint.x, startPoint.y, x - startPoint.x, y - startPoint.y); >+ } else if (toolAction.getKind() == SelectDrawToolAction.DrawKind.OVAL) { >+ workImageGC.drawOval(startPoint.x, startPoint.y, x - startPoint.x, y - startPoint.y); >+ } >+ } >+ } > canvas.redraw(); > } > } >Index: src/org/eclipse/mylyn/internal/provisional/commons/ui/CommonImages.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.commons.ui/src/org/eclipse/mylyn/internal/provisional/commons/ui/CommonImages.java,v >retrieving revision 1.11 >diff -u -r1.11 CommonImages.java >--- src/org/eclipse/mylyn/internal/provisional/commons/ui/CommonImages.java 3 Dec 2008 02:39:31 -0000 1.11 >+++ src/org/eclipse/mylyn/internal/provisional/commons/ui/CommonImages.java 26 Feb 2009 10:58:32 -0000 >@@ -155,6 +155,14 @@ > > public static final ImageDescriptor EDIT = create(T_TOOL, "edit.gif"); //$NON-NLS-1$ > >+ public static final ImageDescriptor EDIT_FREE = create(T_TOOL, "edit_free.gif"); //$NON-NLS-1$ >+ >+ public static final ImageDescriptor EDIT_LINE = create(T_TOOL, "edit_line.gif"); //$NON-NLS-1$ >+ >+ public static final ImageDescriptor EDIT_BOX = create(T_TOOL, "edit_box.gif"); //$NON-NLS-1$ >+ >+ public static final ImageDescriptor EDIT_OVAL = create(T_TOOL, "edit_oval.gif"); //$NON-NLS-1$ >+ > public static final ImageDescriptor CUT = create(T_TOOL, "cut.gif"); //$NON-NLS-1$ > > public static final ImageDescriptor STATUS_NORMAL = create(T_EVIEW, "status-normal.gif"); //$NON-NLS-1$ >@@ -201,6 +209,12 @@ > > public static final ImageDescriptor FIND = create(T_TOOL, "find.gif"); //$NON-NLS-1$ > >+ public static final ImageDescriptor FILE_OBJ = create(T_TOOL, "file_obj.gif"); //$NON-NLS-1$ >+ >+ public static final ImageDescriptor CLIPBOARD_OBJ = create(T_TOOL, "clipboard_obj.gif"); //$NON-NLS-1$ >+ >+ public static final ImageDescriptor MINITOR_OBJ = create(T_TOOL, "monitor_obj.gif"); //$NON-NLS-1$ >+ > private static ImageDescriptor create(String prefix, String name) { > try { > return ImageDescriptor.createFromURL(makeIconFileURL(prefix, name)); >Index: src/org/eclipse/mylyn/internal/commons/ui/Messages.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.commons.ui/src/org/eclipse/mylyn/internal/commons/ui/Messages.java,v >retrieving revision 1.2 >diff -u -r1.2 Messages.java >--- src/org/eclipse/mylyn/internal/commons/ui/Messages.java 10 Jan 2009 08:39:37 -0000 1.2 >+++ src/org/eclipse/mylyn/internal/commons/ui/Messages.java 26 Feb 2009 10:58:31 -0000 >@@ -70,4 +70,18 @@ > public static String ScreenshotCreationPage_Fit_Image_F; > > public static String ScreenshotCreationPage_NOTE_THAT_YOU_CONTINUTE; >+ >+ public static String SelectCaptureAction_Clipboard; >+ >+ public static String SelectCaptureAction_Desktop; >+ >+ public static String SelectCaptureAction_File; >+ >+ public static String SelectDrawToolAction_Box; >+ >+ public static String SelectDrawToolAction_Oval; >+ >+ public static String SelectDrawToolAction_Free; >+ >+ public static String SelectDrawToolAction_Line; > } >Index: src/org/eclipse/mylyn/internal/commons/ui/messages.properties >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.commons.ui/src/org/eclipse/mylyn/internal/commons/ui/messages.properties,v >retrieving revision 1.2 >diff -u -r1.2 messages.properties >--- src/org/eclipse/mylyn/internal/commons/ui/messages.properties 10 Jan 2009 08:39:37 -0000 1.2 >+++ src/org/eclipse/mylyn/internal/commons/ui/messages.properties 26 Feb 2009 10:58:31 -0000 >@@ -15,8 +15,8 @@ > > ScreenshotCreationPage_After_capturing=After capturing, you can crop the image and make drawings on it. This window will not be captured. > ScreenshotCreationPage_Annotate=&Annotate >-ScreenshotCreationPage_Capture_Desktop=Capture Desktop >-ScreenshotCreationPage_Capture_Desktop_C=&Capture Desktop >+ScreenshotCreationPage_Capture_Desktop=Capture Desktop, Clipboard or File >+ScreenshotCreationPage_Capture_Desktop_C=&Capture > ScreenshotCreationPage_CAPTURE_SCRRENSHOT=Capture Screenshot > ScreenshotCreationPage_Change_pen_color=Change pen color > ScreenshotCreationPage_Clear_all_annotations_made_on_screenshot_image=Clear all annotations made on screenshot image >@@ -27,3 +27,12 @@ > ScreenshotCreationPage_Fit_Image=Fit Image > ScreenshotCreationPage_Fit_Image_F=&Fit Image > ScreenshotCreationPage_NOTE_THAT_YOU_CONTINUTE=Note that you can continue to interact with the workbench in order to set up the screenshot. >+ >+SelectCaptureAction_Clipboard=Clipboard >+SelectCaptureAction_Desktop=Desktop >+SelectCaptureAction_File=File... >+ >+SelectDrawToolAction_Box=Rectangle >+SelectDrawToolAction_Oval=Oval >+SelectDrawToolAction_Free=Free >+SelectDrawToolAction_Line=Line >Index: src/org/eclipse/mylyn/internal/provisional/commons/ui/SelectCaptureAction.java >=================================================================== >RCS file: src/org/eclipse/mylyn/internal/provisional/commons/ui/SelectCaptureAction.java >diff -N src/org/eclipse/mylyn/internal/provisional/commons/ui/SelectCaptureAction.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylyn/internal/provisional/commons/ui/SelectCaptureAction.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,171 @@ >+package org.eclipse.mylyn.internal.provisional.commons.ui; >+ >+import org.eclipse.jface.action.Action; >+import org.eclipse.jface.action.ActionContributionItem; >+import org.eclipse.jface.action.IMenuCreator; >+import org.eclipse.jface.resource.ImageDescriptor; >+import org.eclipse.mylyn.internal.commons.ui.Messages; >+import org.eclipse.swt.dnd.Clipboard; >+import org.eclipse.swt.dnd.ImageTransfer; >+import org.eclipse.swt.graphics.Image; >+import org.eclipse.swt.graphics.ImageData; >+import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.FileDialog; >+import org.eclipse.swt.widgets.Menu; >+import org.eclipse.swt.widgets.Shell; >+ >+public class SelectCaptureAction extends Action implements IMenuCreator { >+ >+ public static final String ID = "org.eclipse.mylyn.common.ui.actions.selectcapture"; //$NON-NLS-1$ >+ >+ public enum Selection { >+ CAPTURE, CLIPBOARD, FILE >+ }; >+ >+ private static final Selection[] selections = { Selection.CAPTURE, Selection.CLIPBOARD, Selection.FILE }; >+ >+ private static final String[] labels = { Messages.SelectCaptureAction_Desktop, >+ Messages.SelectCaptureAction_Clipboard, Messages.SelectCaptureAction_File }; >+ >+ private static final ImageDescriptor[] images = { CommonImages.MINITOR_OBJ, CommonImages.CLIPBOARD_OBJ, >+ CommonImages.FILE_OBJ }; >+ >+ private Selection kind; >+ >+ private Menu dropDownMenu; >+ >+ private final Shell shell; >+ >+ private String filename; >+ >+ public SelectCaptureAction(Shell shell, String label) { >+ super(label); >+ setMenuCreator(this); >+ setId(ID); >+ kind = selections[0]; >+ this.shell = shell; >+ } >+ >+ public Selection getKind() { >+ return kind; >+ } >+ >+ public void resetKind() { >+ kind = selections[0]; >+ } >+ >+ private void setKindAndRun(String label) { >+ kind = selections[0]; >+ for (int m = 0; m < labels.length; m++) { >+ if (labels[m].equals(label)) { >+ kind = selections[m]; >+ if (selections[m] == Selection.FILE) { >+ FileDialog dialog = new FileDialog(shell); >+ dialog.setFileName(filename); >+ dialog.setFilterExtensions(new String[] { "*.bmp;*.jpg;*.png", "*.*" }); //$NON-NLS-1$ //$NON-NLS-2$ >+ String result = dialog.open(); >+ if (result != null && result.length() > 0) { >+ filename = result; >+ } else { >+ break; >+ } >+ } >+ run(); >+ break; >+ } >+ } >+ } >+ >+ private void addActionsToMenu() { >+ kind = selections[0]; >+ for (int m = 0; m < labels.length; m++) { >+ SelectionAction action = new SelectionAction(); >+ ActionContributionItem item = new ActionContributionItem(action); >+ action.setText(labels[m]); >+ action.setImageDescriptor(images[m]); >+ if (selections[m] == Selection.CLIPBOARD) { >+ action.setEnabled(existImageOnClipboard()); >+ } >+ item.fill(dropDownMenu, -1); >+ } >+ } >+ >+ public void dispose() { >+ if (dropDownMenu != null) { >+ dropDownMenu.dispose(); >+ dropDownMenu = null; >+ } >+ } >+ >+ public Menu getMenu(Control parent) { >+ if (dropDownMenu != null) { >+ dropDownMenu.dispose(); >+ } >+ dropDownMenu = new Menu(parent); >+ addActionsToMenu(); >+ return dropDownMenu; >+ } >+ >+ public Menu getMenu(Menu parent) { >+ if (dropDownMenu != null) { >+ dropDownMenu.dispose(); >+ } >+ dropDownMenu = new Menu(parent); >+ addActionsToMenu(); >+ return dropDownMenu; >+ } >+ >+ private class SelectionAction extends Action { >+ @Override >+ public void run() { >+ setKindAndRun(getText()); >+ } >+ } >+ >+ public Image getScreenshotImage() { >+ if (kind == Selection.CAPTURE) { >+ return null; >+ } >+ >+ if (kind == Selection.CLIPBOARD) { >+ return getClipboardImage(); >+ } >+ >+ try { >+ Image image = new Image(shell.getDisplay(), filename); >+ return image; >+ } catch (Exception e) { >+ // None >+ } >+ return null; >+ } >+ >+ private Image getClipboardImage() { >+ try { >+ Clipboard clipboard = new Clipboard(shell.getDisplay()); >+ ImageTransfer imageTransfer = ImageTransfer.getInstance(); >+ Object data = clipboard.getContents(imageTransfer); >+ if (data instanceof ImageData) { >+ Image image = new Image(shell.getDisplay(), (ImageData) data); >+ return image; >+ } >+ } catch (Exception e) { >+ // None >+ } >+ return null; >+ } >+ >+ private boolean existImageOnClipboard() { >+ try { >+ Clipboard clipboard = new Clipboard(shell.getDisplay()); >+ ImageTransfer imageTransfer = ImageTransfer.getInstance(); >+ Object data = clipboard.getContents(imageTransfer); >+ if (data instanceof ImageData) { >+ return true; >+ } >+ } catch (Exception e) { >+ // None >+ } >+ return false; >+ } >+} >Index: src/org/eclipse/mylyn/internal/provisional/commons/ui/SelectDrawToolAction.java >=================================================================== >RCS file: src/org/eclipse/mylyn/internal/provisional/commons/ui/SelectDrawToolAction.java >diff -N src/org/eclipse/mylyn/internal/provisional/commons/ui/SelectDrawToolAction.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylyn/internal/provisional/commons/ui/SelectDrawToolAction.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,99 @@ >+package org.eclipse.mylyn.internal.provisional.commons.ui; >+ >+import org.eclipse.jface.action.Action; >+import org.eclipse.jface.action.ActionContributionItem; >+import org.eclipse.jface.action.IMenuCreator; >+import org.eclipse.jface.resource.ImageDescriptor; >+import org.eclipse.mylyn.internal.commons.ui.Messages; >+import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.Menu; >+ >+public class SelectDrawToolAction extends Action implements IMenuCreator { >+ >+ public static final String ID = "org.eclipse.mylyn.common.ui.actions.selectdrawtool"; //$NON-NLS-1$ >+ >+ public enum DrawKind { >+ FREE, LINE, BOX, OVAL >+ }; >+ >+ private final DrawKind[] kinds = { DrawKind.FREE, DrawKind.LINE, DrawKind.BOX, DrawKind.OVAL }; >+ >+ private final String[] labels = { Messages.SelectDrawToolAction_Free, Messages.SelectDrawToolAction_Line, >+ Messages.SelectDrawToolAction_Box, Messages.SelectDrawToolAction_Oval }; >+ >+ private final ImageDescriptor[] images = { CommonImages.EDIT_FREE, CommonImages.EDIT_LINE, CommonImages.EDIT_BOX, >+ CommonImages.EDIT_OVAL }; >+ >+ private DrawKind kind; >+ >+ private Menu dropDownMenu; >+ >+ public SelectDrawToolAction() { >+ super(); >+ setMenuCreator(this); >+ setId(ID); >+ setImageDescriptor(images[0]); >+ setToolTipText(labels[0]); >+ kind = kinds[0]; >+ } >+ >+ public DrawKind getKind() { >+ return kind; >+ } >+ >+ private void setKind(String label, ImageDescriptor image) { >+ kind = kinds[0]; >+ for (int m = 0; m < labels.length; m++) { >+ if (labels[m].equals(label)) { >+ kind = kinds[m]; >+ setToolTipText(label); >+ setImageDescriptor(image); >+ break; >+ } >+ } >+ } >+ >+ private void addActionsToMenu() { >+ for (int m = 0; m < labels.length; m++) { >+ SelectionAction action = new SelectionAction(); >+ ActionContributionItem item = new ActionContributionItem(action); >+ action.setText(labels[m]); >+ action.setImageDescriptor(images[m]); >+ action.setChecked(kinds[m] == kind); >+ item.fill(dropDownMenu, -1); >+ } >+ } >+ >+ public void dispose() { >+ if (dropDownMenu != null) { >+ dropDownMenu.dispose(); >+ dropDownMenu = null; >+ } >+ } >+ >+ public Menu getMenu(Control parent) { >+ if (dropDownMenu != null) { >+ dropDownMenu.dispose(); >+ } >+ dropDownMenu = new Menu(parent); >+ addActionsToMenu(); >+ return dropDownMenu; >+ } >+ >+ public Menu getMenu(Menu parent) { >+ if (dropDownMenu != null) { >+ dropDownMenu.dispose(); >+ } >+ dropDownMenu = new Menu(parent); >+ addActionsToMenu(); >+ return dropDownMenu; >+ } >+ >+ private class SelectionAction extends Action { >+ @Override >+ public void run() { >+ setKind(getText(), getImageDescriptor()); >+ } >+ } >+ >+}
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 266123
:
126712
|
126835
|
126836
|
127074
|
127102
|
127103
|
127110
|
127892
|
127914
|
127915
|
128171
|
134062
|
134063
|
134067
|
134078
|
134195
|
134984
|
135048
|
135049