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 127110 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]
screenshot.patch
screenshot.patch (text/plain), 56.59 KB, created by
Hiroyuki
on 2009-03-01 10:42:24 EST
(
hide
)
Description:
screenshot.patch
Filename:
MIME Type:
Creator:
Hiroyuki
Created:
2009-03-01 10:42:24 EST
Size:
56.59 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 1 Mar 2009 15:39:16 -0000 >@@ -32,8 +32,8 @@ > import org.eclipse.jface.layout.GridDataFactory; > import org.eclipse.jface.resource.ImageDescriptor; > import org.eclipse.jface.wizard.WizardPage; >-import org.eclipse.mylyn.internal.commons.ui.ColorSelectionWindow; > import org.eclipse.mylyn.internal.commons.ui.Messages; >+import org.eclipse.osgi.util.NLS; > import org.eclipse.swt.SWT; > import org.eclipse.swt.custom.ScrolledComposite; > import org.eclipse.swt.custom.ViewForm; >@@ -46,6 +46,8 @@ > import org.eclipse.swt.events.PaintListener; > import org.eclipse.swt.graphics.Color; > import org.eclipse.swt.graphics.Cursor; >+import org.eclipse.swt.graphics.Font; >+import org.eclipse.swt.graphics.FontData; > import org.eclipse.swt.graphics.GC; > import org.eclipse.swt.graphics.Image; > import org.eclipse.swt.graphics.Point; >@@ -53,11 +55,14 @@ > import org.eclipse.swt.graphics.Rectangle; > import org.eclipse.swt.graphics.Region; > import org.eclipse.swt.widgets.Canvas; >+import org.eclipse.swt.widgets.ColorDialog; > import org.eclipse.swt.widgets.Composite; > import org.eclipse.swt.widgets.Display; > import org.eclipse.swt.widgets.Event; >+import org.eclipse.swt.widgets.FontDialog; >+import org.eclipse.swt.widgets.Listener; > import org.eclipse.swt.widgets.Shell; >-import org.eclipse.swt.widgets.ToolItem; >+import org.eclipse.swt.widgets.Text; > import org.eclipse.ui.progress.UIJob; > > /** >@@ -71,14 +76,26 @@ > */ > public class ScreenshotCreationPage extends WizardPage implements IImageCreator { > >- private IAction captureAction; >+ private SelectCaptureAction captureAction; > >- private IAction fitAction; >+ private SelectZoomToolAction fitAction; > > private IAction cropAction; > > private IAction markAction; > >+ private SelectDrawToolAction toolAction; >+ >+ private SelectLineToolAction lineAction; >+ >+ private SelectBoldToolAction boldAction; >+ >+ private IAction fontAction; >+ >+ private Font markFont; >+ >+ private Color markFontColor; >+ > private IAction colorAction; > > private Image colorIcon; >@@ -87,6 +104,10 @@ > > private IAction clearAction; > >+ private IAction undoAction; >+ >+ private IAction redoAction; >+ > private boolean imageDirty; > > /** >@@ -99,6 +120,8 @@ > */ > private Image workImage; > >+ private Image previousImage; >+ > /** > * Used to draw into {@link #workImage} > */ >@@ -155,6 +178,31 @@ > */ > private EditorAction currentAction = EditorAction.CROPPING; > >+ private boolean isFirstCapture = true; >+ >+ /** >+ * Mouse event history. Entry is [0] MouseDown/MouseMove/MouseUp, [1] x, [2] y >+ */ >+ private Text textArea; >+ >+ /** >+ * Mouse event history. Entry is [0] MouseDown/MouseMove/MouseUp, [1] x, [2] y >+ */ >+ private List<int[]> historyMouseEvent = new ArrayList<int[]>(); >+ >+ /** >+ * Draw tool history. Entry is [0] drawHistory index, [1] FREE/LINE/BOX/OVAL, [2] Line type, [3] Bold, [4] R/G/B >+ */ >+ private List<int[]> historyDrawTool = new ArrayList<int[]>(); >+ >+ private List<StringBuffer> historyDrawText = new ArrayList<StringBuffer>(); >+ >+ private List<String> historyDrawFont = new ArrayList<String>(); >+ >+ private int historyCheckpoint = 0; >+ >+ // MouseDown [1, x, y], MouseMove [2, x, y], MouseUp [0, x, y] >+ > public ScreenshotCreationPage() { > super("ScreenShotAttachment"); //$NON-NLS-1$ > setTitle(Messages.ScreenshotCreationPage_CAPTURE_SCRRENSHOT); >@@ -173,13 +221,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.CAPTURE) { >+ captureScreenshotContent(); >+ } else { >+ captureScreenshotContent(captureAction.getScreenshotImage()); >+ } >+ captureAction.resetKind(); > setErrorMessage(null); > if (isFirstCapture) { > isFirstCapture = false; >@@ -189,11 +241,20 @@ > markAction.setEnabled(true); > clearAction.setEnabled(false); > } >+ >+ historyMouseEvent = new ArrayList<int[]>(); >+ historyDrawTool = new ArrayList<int[]>(); >+ historyDrawText = new ArrayList<StringBuffer>(); >+ historyDrawFont = new ArrayList<String>(); >+ historyCheckpoint = 0; >+ undoAction.setEnabled(false); >+ redoAction.setEnabled(false); > } > > }; > captureAction.setToolTipText(Messages.ScreenshotCreationPage_Capture_Desktop); > captureAction.setImageDescriptor(ImageDescriptor.createFromImage(CommonImages.getImage(CommonImages.IMAGE_CAPTURE))); >+ captureAction.setShowMenuAlways(false); > > // captureDelayedButton = new Button(buttonsComposite, SWT.PUSH); > // final String captureIn = "Capture in "; >@@ -228,7 +289,7 @@ > // } > // }); > >- fitAction = new Action("", IAction.AS_CHECK_BOX) { //$NON-NLS-1$ >+ fitAction = new SelectZoomToolAction() { > @Override > public void run() { > refreshCanvasSize(); >@@ -237,7 +298,7 @@ > fitAction.setToolTipText(Messages.ScreenshotCreationPage_Fit_Image); > fitAction.setText(Messages.ScreenshotCreationPage_Fit_Image_F); > fitAction.setImageDescriptor(ImageDescriptor.createFromImage(CommonImages.getImage(CommonImages.IMAGE_FIT))); >- fitAction.setChecked(true); >+ //fitAction.setChecked(true); > fitAction.setEnabled(false); > > cropAction = new Action(Messages.ScreenshotCreationPage_Crop_R, IAction.AS_RADIO_BUTTON) { >@@ -246,7 +307,13 @@ > currentAction = EditorAction.CROPPING; > cropAction.setChecked(true); > markAction.setChecked(false); >+ toolAction.setEnabled(false); >+ lineAction.setEnabled(false); >+ boldAction.setEnabled(false); >+ fontAction.setEnabled(false); > colorAction.setEnabled(false); >+ undoAction.setEnabled(false); >+ redoAction.setEnabled(false); > canvas.redraw(); > } > }; >@@ -260,7 +327,13 @@ > currentAction = EditorAction.MARKING; > cropAction.setChecked(false); > markAction.setChecked(true); >+ toolAction.setEnabled(true); >+ lineAction.setEnabled(true); >+ boldAction.setEnabled(true); >+ fontAction.setEnabled(toolAction.getKind() == SelectDrawToolAction.TEXT); > colorAction.setEnabled(true); >+ undoAction.setEnabled(false); >+ redoAction.setEnabled(false); > canvas.redraw(); > } > }; >@@ -269,25 +342,43 @@ > // markAction.setDisabledImageDescriptor(ImageDescriptor.createFromFile(getClass(), "mark_disabled.gif")); > markAction.setEnabled(false); > >- colorAction = new Action("", IAction.AS_DROP_DOWN_MENU) { //$NON-NLS-1$ >+ toolAction = new SelectDrawToolAction() { > @Override >- public void runWithEvent(final Event e) { >- final ColorSelectionWindow colorWindow = new ColorSelectionWindow(getControl().getShell()) { >+ public void run() { >+ fontAction.setEnabled(toolAction.getKind() == SelectDrawToolAction.TEXT); >+ } >+ }; >+ toolAction.setEnabled(false); >+ >+ lineAction = new SelectLineToolAction(); >+ lineAction.setEnabled(false); >+ >+ boldAction = new SelectBoldToolAction(); >+ boldAction.setEnabled(false); > >- @Override >- protected Point getInitialLocation(Point initialSize) { >- ToolItem toolItem = (ToolItem) e.widget; >- Rectangle itemBounds = toolItem.getBounds(); >- Point location = toolItem.getParent().toDisplay(itemBounds.x + itemBounds.width, >- itemBounds.y + itemBounds.height); >- location.x -= initialSize.x; >- return location; >- } >- >- }; >- colorWindow.setBlockOnOpen(true); >- colorWindow.open(); >- RGB color = colorWindow.getSelectedRGB(); >+ colorAction = new Action("", IAction.AS_PUSH_BUTTON) { //$NON-NLS-1$ >+ @Override >+ public void runWithEvent(final Event e) { >+// final ColorSelectionWindow colorWindow = new ColorSelectionWindow(getControl().getShell()) { >+// >+// @Override >+// protected Point getInitialLocation(Point initialSize) { >+// ToolItem toolItem = (ToolItem) e.widget; >+// Rectangle itemBounds = toolItem.getBounds(); >+// Point location = toolItem.getParent().toDisplay(itemBounds.x + itemBounds.width, >+// itemBounds.y + itemBounds.height); >+// location.x -= initialSize.x; >+// return location; >+// } >+// >+// }; >+// colorWindow.setBlockOnOpen(true); >+// colorWindow.open(); >+// RGB color = colorWindow.getSelectedRGB(); >+ final ColorDialog colorWindow = new ColorDialog(getControl().getShell()); >+ colorWindow.setRGB(markColor.getRGB()); >+ RGB color = colorWindow.open(); >+ ; > if (color != null) { > setMarkColor(color); > } >@@ -298,27 +389,99 @@ > setMarkColor(new RGB(255, 85, 85)); > colorAction.setEnabled(false); > >- clearAction = new Action(Messages.ScreenshotCreationPage_Clear_Annotations, IAction.AS_PUSH_BUTTON) { >+ fontAction = new Action("", IAction.AS_PUSH_BUTTON) { //$NON-NLS-1$ >+ @Override >+ public void runWithEvent(final Event e) { >+ final FontDialog fontWindow = new FontDialog(getControl().getShell()); >+ fontWindow.setFontList(markFont.getFontData()); >+ fontWindow.setRGB(markFontColor.getRGB()); >+ FontData fontData = fontWindow.open(); >+ RGB fontColor = fontWindow.getRGB(); >+ if (fontData != null) { >+ setMarkFont(new FontData[] { fontData }, fontColor); >+ fontAction.setToolTipText(getMarkFontInfo()); >+ } >+ } >+ }; >+ setMarkFont(getShell().getFont().getFontData(), new RGB(255, 0, 0)); >+ fontAction.setToolTipText(getMarkFontInfo()); >+ fontAction.setImageDescriptor(CommonImages.FONT_PROP); >+ fontAction.setEnabled(false); >+ >+ clearAction = new Action(Messages.ScreenshotCreationPage_Clear, IAction.AS_PUSH_BUTTON) { > @Override > public void run() { > clearAction.setEnabled(false); > workImageGC.drawImage(originalImage, 0, 0); > canvas.redraw(); > setImageDirty(true); >+ >+ historyMouseEvent = new ArrayList<int[]>(); >+ historyDrawTool = new ArrayList<int[]>(); >+ historyDrawText = new ArrayList<StringBuffer>(); >+ historyDrawFont = new ArrayList<String>(); >+ historyCheckpoint = 0; >+ undoAction.setEnabled(false); >+ redoAction.setEnabled(false); > } > }; > clearAction.setToolTipText(Messages.ScreenshotCreationPage_Clear_all_annotations_made_on_screenshot_image); > clearAction.setImageDescriptor(CommonImages.CLEAR); > clearAction.setEnabled(false); > >+ undoAction = new Action(Messages.ScreenshotCreationPage_Undo) { >+ @Override >+ public void run() { >+ if (historyCheckpoint > 0) { >+ historyCheckpoint--; >+ drawAnnotationHistory(); >+ } >+ if (historyCheckpoint == 0) { >+ undoAction.setEnabled(false); >+ } >+ if (historyCheckpoint < historyDrawTool.size()) { >+ redoAction.setEnabled(true); >+ } >+ } >+ }; >+ undoAction.setToolTipText(Messages.ScreenshotCreationPage_Undo_annotation); >+ undoAction.setImageDescriptor(CommonImages.EDIT_UNDO); >+ undoAction.setEnabled(false); >+ >+ redoAction = new Action(Messages.ScreenshotCreationPage_Redo) { >+ @Override >+ public void run() { >+ if (historyCheckpoint < historyDrawTool.size()) { >+ historyCheckpoint++; >+ drawAnnotationHistory(); >+ } >+ if (historyCheckpoint > 0) { >+ undoAction.setEnabled(true); >+ } >+ if (historyCheckpoint >= historyDrawTool.size()) { >+ redoAction.setEnabled(false); >+ } >+ } >+ }; >+ redoAction.setToolTipText(Messages.ScreenshotCreationPage_Redo_annotation); >+ redoAction.setImageDescriptor(CommonImages.EDIT_REDO); >+ redoAction.setEnabled(false); >+ > tbm.add(createAndConfigureCI(captureAction)); >- tbm.add(createAndConfigureCI(fitAction)); > tbm.add(new Separator()); >+ tbm.add(createAndConfigureCI(fitAction)); > tbm.add(createAndConfigureCI(cropAction)); > tbm.add(createAndConfigureCI(markAction)); >+ tbm.add(new Separator()); >+ tbm.add(createAndConfigureCI(toolAction)); >+ tbm.add(createAndConfigureCI(lineAction)); >+ tbm.add(createAndConfigureCI(boldAction)); > tbm.add(createAndConfigureCI(colorAction)); >+ tbm.add(createAndConfigureCI(fontAction)); > tbm.add(new Separator()); > tbm.add(createAndConfigureCI(clearAction)); >+ tbm.add(createAndConfigureCI(undoAction)); >+ tbm.add(createAndConfigureCI(redoAction)); > > scrolledComposite = new ScrolledComposite(vf, SWT.V_SCROLL | SWT.H_SCROLL); > canvas = new Canvas(scrolledComposite, SWT.DOUBLE_BUFFERED); >@@ -330,11 +493,26 @@ > Rectangle imageBounds = workImage.getBounds(); > Rectangle canvasBounds = canvas.getClientArea(); > >- if (fitAction.isChecked()) { >- e.gc.drawImage(workImage, 0, 0, imageBounds.width, imageBounds.height, 0, 0, >- canvasBounds.width, canvasBounds.height); >- } else { >+ switch (fitAction.getKind()) { >+ case SelectZoomToolAction.FIT: >+ e.gc.drawImage(workImage, 0, 0, imageBounds.width, imageBounds.height, // >+ 0, 0, canvasBounds.width, canvasBounds.height); >+ break; >+ case SelectZoomToolAction.ZOOM8X: >+ e.gc.drawImage(workImage, 0, 0, imageBounds.width, imageBounds.height, // >+ 0, 0, imageBounds.width * 8, imageBounds.height * 8); >+ break; >+ case SelectZoomToolAction.ZOOM4X: >+ e.gc.drawImage(workImage, 0, 0, imageBounds.width, imageBounds.height, // >+ 0, 0, imageBounds.width * 4, imageBounds.height * 4); >+ break; >+ case SelectZoomToolAction.ZOOM2X: >+ e.gc.drawImage(workImage, 0, 0, imageBounds.width, imageBounds.height, // >+ 0, 0, imageBounds.width * 2, imageBounds.height * 2); >+ break; >+ default: > e.gc.drawImage(workImage, 0, 0); >+ break; > } > drawSelection(e.gc); > } else { >@@ -347,7 +525,7 @@ > scrolledComposite.addControlListener(new ControlAdapter() { > @Override > public void controlResized(ControlEvent e) { >- if (fitAction.isChecked()) { >+ if (fitAction.getKind() == SelectZoomToolAction.FIT) { > refreshCanvasSize(); > } > } >@@ -367,6 +545,31 @@ > return ci; > } > >+ private void setMarkFont(FontData[] fontData, RGB fontColor) { >+ if (markFont != null) { >+ markFont.dispose(); >+ } >+ markFont = new Font(getShell().getDisplay(), fontData[0]); >+ markFontColor = new Color(getShell().getDisplay(), fontColor); >+ } >+ >+ private String getMarkFontInfo() { >+ if (markFont == null) { >+ return Messages.ScreenshotCreationPage_Change_text_font; >+ } >+ FontData[] fd = markFont.getFontData(); >+ String info = NLS.bind(Messages.ScreenshotCreationPage_Font_Name_Size, // >+ new Object[] { fd[0].getName(), fd[0].getHeight() + "" }); //$NON-NLS-1$ >+ int style = fd[0].getStyle(); >+ if ((style & SWT.BOLD) != 0) { >+ info = info + Messages.ScreenshotCreationPage_Font_Bold; >+ } >+ if ((style & SWT.ITALIC) != 0) { >+ info = info + Messages.ScreenshotCreationPage_Font_Italic; >+ } >+ return info; >+ } >+ > private void setMarkColor(RGB color) { > if (markColor != null) { > markColor.dispose(); >@@ -455,6 +658,29 @@ > 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.setBackground(new Color(getShell().getDisplay(), 255, 255, 255)); >+ 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(); >@@ -659,6 +885,28 @@ > canvas.setCursor(crossCursor); > } > } else if (currentAction == EditorAction.MARKING) { >+ if (startPoint != null) { >+ if (toolAction.getKind() == SelectDrawToolAction.FREE) { >+ int[] history = new int[3]; >+ history[0] = SWT.MouseMove; >+ history[1] = scaledX; >+ history[2] = scaledY; >+ historyMouseEvent.add(history); >+ } else { >+ int[] history = historyMouseEvent.get(historyMouseEvent.size() - 1); >+ if (history[0] == SWT.MouseMove) { >+ history[1] = scaledX; >+ history[2] = scaledY; >+ } else { >+ history = new int[3]; >+ history[0] = SWT.MouseMove; >+ history[1] = scaledX; >+ history[2] = scaledY; >+ historyMouseEvent.add(history); >+ } >+ } >+ } >+ > drawMarkLine(scaledX, scaledY); > > Cursor markCursor = cursors.get(CURSOR_MARK_TOOL); >@@ -699,9 +947,129 @@ > canvas.redraw(); > setImageDirty(true); > } else if (currentAction == EditorAction.MARKING) { >+ if (startPoint != null) { >+ if (toolAction.getKind() != SelectDrawToolAction.FREE) { >+ if (toolAction.getKind() == SelectDrawToolAction.TEXT) { >+ drawAnnotationText(); >+ } >+ previousImage.dispose(); >+ previousImage = null; >+ } >+ >+ int[] history = new int[3]; >+ history[0] = SWT.MouseUp; >+ history[1] = 0; >+ history[2] = 0; >+ historyMouseEvent.add(history); >+ } >+ > startPoint = null; > setImageDirty(true); >+ >+ } >+ } >+ >+ /** >+ * Input annotation text and draw text >+ */ >+ private void drawAnnotationText() { >+ workImageGC.drawImage(previousImage, 0, 0); >+ >+ int[] history = historyMouseEvent.get(historyMouseEvent.size() - 1); >+ if (history[0] != SWT.MouseMove) { >+ historyCheckpoint--; >+ updateAnnotationHistory(); >+ return; >+ } >+ >+ final Rectangle bounds = new Rectangle(startPoint.x, startPoint.y, history[1] - startPoint.x, >+ history[2] - startPoint.y); >+ >+ textArea = new Text(canvas, SWT.MULTI | SWT.WRAP); >+ textArea.addListener(SWT.Deactivate, new Listener() { >+ >+ public void handleEvent(Event event) { >+ String text = textArea.getText(); >+ { >+ String newtext = ""; //$NON-NLS-1$ >+ int currpos = 0; >+ int charpos = currpos; >+ textArea.setTopIndex(0); >+ textArea.setSelection(currpos); >+ int linepos = textArea.getCaretLineNumber(); >+ boolean remove1st = false; >+ String line; >+ while (currpos < text.length()) { >+ int y = textArea.getCaretLineNumber(); >+ if (linepos != y) { >+ line = text.substring(charpos, currpos); >+ if (line.endsWith("\n")) { //$NON-NLS-1$ >+ line = line.substring(0, line.length() - 1); >+ } >+ newtext = newtext + "\n" + line; //$NON-NLS-1$ >+ remove1st = true; >+ charpos = currpos; >+ linepos = y; >+ } >+ currpos++; >+ textArea.setSelection(currpos); >+ } >+ line = text.substring(charpos, currpos); >+ if (line.endsWith("\n")) { //$NON-NLS-1$ >+ line = line.substring(0, line.length() - 1); >+ } >+ if (line.length() > 0) { >+ newtext = newtext + "\n" + text.substring(charpos, currpos); //$NON-NLS-1$ >+ remove1st = true; >+ } >+ currpos = newtext.indexOf("\r"); //$NON-NLS-1$ >+ while (currpos > 0) { >+ newtext = newtext.substring(0, currpos) + newtext.substring(currpos + 1); >+ currpos = newtext.indexOf("\r"); //$NON-NLS-1$ >+ } >+ newtext = newtext.replace("\t", " "); //$NON-NLS-1$ //$NON-NLS-2$ >+ if (remove1st) { >+ newtext = newtext.substring(1); >+ } >+ text = newtext; >+ } >+ >+ textArea.dispose(); >+ textArea = null; >+ >+ if (text.length() > 0) { >+ historyDrawText.get(historyCheckpoint - 1).append(text); >+ workImageGC.setFont(markFont); >+ workImageGC.setForeground(markFontColor); >+ workImageGC.setClipping(bounds); >+ workImageGC.drawText(text, bounds.x, bounds.y, true); >+ workImageGC.setClipping((Rectangle) null); >+ workImageGC.setForeground(markColor); >+ } else { >+ historyCheckpoint--; >+ updateAnnotationHistory(); >+ } >+ canvas.redraw(); >+ } >+ }); >+ >+ textArea.setFocus(); >+ int xs = (int) Math.round(startPoint.x * scaleFactor); >+ int ys = (int) Math.round(startPoint.y * scaleFactor); >+ int xe = (int) Math.round(history[1] * scaleFactor); >+ int ye = (int) Math.round(history[2] * scaleFactor); >+ textArea.setBounds(new Rectangle(xs, ys, xe - xs, ye - ys)); >+ if (scaleFactor != 1.0) { >+ FontData[] fd = markFont.getFontData(); >+ fd[0].setHeight((int) Math.round(fd[0].getHeight() * scaleFactor)); >+ textArea.setFont(new Font(getShell().getDisplay(), fd[0])); >+ } else { >+ textArea.setFont(markFont); > } >+ textArea.setForeground(markFontColor); >+ textArea.setTabs(1); >+ Point point = textArea.getCaretLocation(); >+ textArea.setBounds(new Rectangle(xs - point.x, ys, xe - xs + point.x + point.x, ye - ys)); > } > > /** >@@ -713,6 +1081,58 @@ > int scaledY = (int) (e.y / scaleFactor); > > if (currentAction == EditorAction.MARKING) { >+ updateAnnotationHistory(); >+ >+ int toolKind = toolAction.getKind(); >+ int[] history = new int[5]; >+ history[0] = historyMouseEvent.size(); >+ history[1] = toolAction.getKind(); >+ history[2] = lineAction.getKind(); >+ history[3] = boldAction.getKind(); >+ if (toolKind == SelectDrawToolAction.TEXT) { >+ history[4] = (markFontColor.getRed() << 16) // >+ + (markFontColor.getGreen() << 8) // >+ + markFontColor.getBlue(); >+ } else { >+ history[4] = (markColor.getRed() << 16) // >+ + (markColor.getGreen() << 8) // >+ + markColor.getBlue(); >+ } >+ historyDrawTool.add(history); >+ historyDrawText.add(new StringBuffer()); >+ if (toolKind == SelectDrawToolAction.TEXT) { >+ FontData[] fd = markFont.getFontData(); >+ historyDrawFont.add(fd[0].toString()); >+ } else { >+ historyDrawFont.add(""); //$NON-NLS-1$ >+ } >+ historyCheckpoint = historyDrawTool.size(); >+ >+ history = new int[3]; >+ history[0] = SWT.MouseDown; >+ history[1] = scaledX; >+ history[2] = scaledY; >+ historyMouseEvent.add(history); >+ undoAction.setEnabled(true); >+ >+ if (toolKind != SelectDrawToolAction.FREE) { >+ Display display = getShell().getDisplay(); >+ previousImage = new Image(display, workImage.getBounds()); >+ GC gc = new GC(previousImage); >+ gc.drawImage(workImage, 0, 0); >+ gc.dispose(); >+ } >+ >+ if (toolKind != SelectDrawToolAction.TEXT) { >+ workImageGC.setLineStyle(lineAction.getKind()); >+ workImageGC.setLineWidth(boldAction.getKind()); >+ workImageGC.setForeground(markColor); >+ } else { >+ workImageGC.setLineStyle(SWT.LINE_DOT); >+ workImageGC.setLineWidth(1); >+ workImageGC.setForeground(new Color(getShell().getDisplay(), 0, 0, 0)); >+ } >+ > startPoint = new Point(scaledX, scaledY); > drawMarkLine(scaledX, scaledY); > canvas.setCursor(cursors.get(CURSOR_MARK_TOOL)); >@@ -779,7 +1199,7 @@ > * Calling this method under other circumstances may lead to strange behavior in the scrolled composite > */ > private void refreshCanvasSize() { >- if (fitAction.isChecked()) { >+ if (fitAction.getKind() == SelectZoomToolAction.FIT) { > // This little hack is necessary to get the client area without scrollbars; > // they'll be automatically restored if necessary after Canvas.setBounds() > scrolledComposite.getHorizontalBar().setVisible(false); >@@ -798,12 +1218,20 @@ > } > canvas.setBounds(bounds); > } else { >- scaleFactor = 1.0; >+ if (fitAction.getKind() == SelectZoomToolAction.ZOOM8X) { >+ scaleFactor = 8.0; >+ } else if (fitAction.getKind() == SelectZoomToolAction.ZOOM4X) { >+ scaleFactor = 4.0; >+ } else if (fitAction.getKind() == SelectZoomToolAction.ZOOM2X) { >+ scaleFactor = 2.0; >+ } else { >+ scaleFactor = 1.0; >+ } > Rectangle bounds = scrolledComposite.getClientArea(); > if (workImage != null) { > Rectangle imageBounds = workImage.getBounds(); >- bounds.width = imageBounds.width; >- bounds.height = imageBounds.height; >+ bounds.width = (int) Math.round(imageBounds.width * scaleFactor); >+ bounds.height = (int) Math.round(imageBounds.height * scaleFactor); > } > canvas.setBounds(bounds); > } >@@ -811,6 +1239,122 @@ > canvas.redraw(); > } > >+ private void updateAnnotationHistory() { >+ int[] history; >+ if (historyCheckpoint < historyDrawTool.size()) { >+ history = historyDrawTool.get(historyCheckpoint); >+ while (history[0] < historyMouseEvent.size()) { >+ historyMouseEvent.remove(historyMouseEvent.size() - 1); >+ } >+ while (historyCheckpoint < historyDrawTool.size()) { >+ historyDrawTool.remove(historyDrawTool.size() - 1); >+ } >+ while (historyCheckpoint < historyDrawText.size()) { >+ historyDrawText.remove(historyDrawText.size() - 1); >+ } >+ while (historyCheckpoint < historyDrawFont.size()) { >+ historyDrawFont.remove(historyDrawFont.size() - 1); >+ } >+ redoAction.setEnabled(false); >+ } >+ >+ undoAction.setEnabled(historyCheckpoint > 0); >+ } >+ >+ /** >+ * Draw Annotation with history >+ */ >+ private void drawAnnotationHistory() { >+ workImageGC.drawImage(originalImage, 0, 0); >+ int[] history; >+ for (int c = 0; c < historyCheckpoint; c++) { >+ history = historyDrawTool.get(c); >+ int toolKind = history[1]; >+ int boldlKind = history[3]; >+ workImageGC.setLineStyle(history[2]); >+ workImageGC.setLineWidth(boldlKind); >+ workImageGC.setForeground(new Color(getShell().getDisplay(), // >+ history[4] >> 16, // >+ (history[4] >> 8) & 0x00ff, // >+ history[4] & 0x00ff)); >+ >+ int h = history[0]; >+ history = historyMouseEvent.get(h); >+ int start_x = history[1]; >+ int start_y = history[2]; >+ for (h++; h < historyMouseEvent.size(); h++) { >+ history = historyMouseEvent.get(h); >+ if (history[0] == SWT.MouseUp) { >+ break; >+ } >+ int x = history[1]; >+ int y = history[2]; >+ if (toolKind == SelectDrawToolAction.FREE) { >+ workImageGC.drawLine(start_x, start_y, x, y); >+ start_x = x; >+ start_y = y; >+ } else { >+ if (start_x == x && start_y == y) { >+ workImageGC.drawLine(start_x, start_y, x, y); >+ } else { >+ Color backColor; >+ int rounded; >+ int width = x - start_x; >+ int height = y - start_y; >+ switch (toolKind) { >+ case SelectDrawToolAction.LINE: >+ workImageGC.drawLine(start_x, start_y, x, y); >+ break; >+ case SelectDrawToolAction.BOX: >+ workImageGC.drawRectangle(start_x, start_y, width, height); >+ break; >+ case SelectDrawToolAction.RBOX: >+ rounded = boldlKind * 8; >+ workImageGC.drawRoundRectangle(start_x, start_y, width, height, rounded, rounded); >+ break; >+ case SelectDrawToolAction.OVAL: >+ workImageGC.drawOval(start_x, start_y, width, height); >+ break; >+ case SelectDrawToolAction.FILL_BOX: >+ backColor = workImageGC.getBackground(); >+ workImageGC.setBackground(workImageGC.getForeground()); >+ workImageGC.fillRectangle(start_x, start_y, width, height); >+ workImageGC.setBackground(backColor); >+ break; >+ case SelectDrawToolAction.FILL_RBOX: >+ rounded = boldlKind * 8; >+ backColor = workImageGC.getBackground(); >+ workImageGC.setBackground(workImageGC.getForeground()); >+ workImageGC.fillRoundRectangle(start_x, start_y, width, height, rounded, rounded); >+ workImageGC.setBackground(backColor); >+ break; >+ case SelectDrawToolAction.FILL_OVAL: >+ backColor = workImageGC.getBackground(); >+ workImageGC.setBackground(workImageGC.getForeground()); >+ workImageGC.fillOval(start_x, start_y, width, height); >+ workImageGC.setBackground(backColor); >+ break; >+ case SelectDrawToolAction.TEXT: >+ StringBuffer text = historyDrawText.get(c); >+ FontData fontData = new FontData(historyDrawFont.get(c)); >+ workImageGC.setFont(new Font(getShell().getDisplay(), fontData)); >+ workImageGC.setClipping(start_x, start_y, width, height); >+ workImageGC.drawText(text.toString(), start_x, start_y, true); >+ workImageGC.setClipping((Rectangle) null); >+ break; >+ } >+ } >+ } >+ } >+ } >+ >+ workImageGC.setForeground(markColor); >+ workImageGC.setLineStyle(lineAction.getKind()); >+ workImageGC.setLineWidth(boldAction.getKind()); >+ workImageGC.setFont(markFont); >+ canvas.redraw(); >+ } >+ > /** > * Decorates the screenshot canvas with the selection rectangle, resize grab points and other adornments > */ >@@ -850,14 +1394,64 @@ > } > > /** >- * 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.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 { >+ Color backColor; >+ int rounded; >+ int width = x - startPoint.x; >+ int height = y - startPoint.y; >+ switch (toolAction.getKind()) { >+ case SelectDrawToolAction.LINE: >+ workImageGC.drawLine(startPoint.x, startPoint.y, x, y); >+ break; >+ case SelectDrawToolAction.BOX: >+ workImageGC.drawRectangle(startPoint.x, startPoint.y, width, height); >+ break; >+ case SelectDrawToolAction.RBOX: >+ rounded = boldAction.getKind() * 8; >+ workImageGC.drawRoundRectangle(startPoint.x, startPoint.y, width, height, rounded, rounded); >+ break; >+ case SelectDrawToolAction.OVAL: >+ workImageGC.drawOval(startPoint.x, startPoint.y, width, height); >+ break; >+ case SelectDrawToolAction.FILL_BOX: >+ backColor = workImageGC.getBackground(); >+ workImageGC.setBackground(markColor); >+ workImageGC.fillRectangle(startPoint.x, startPoint.y, width, height); >+ workImageGC.setBackground(backColor); >+ break; >+ case SelectDrawToolAction.FILL_RBOX: >+ rounded = boldAction.getKind() * 8; >+ backColor = workImageGC.getBackground(); >+ workImageGC.setBackground(markColor); >+ workImageGC.fillRoundRectangle(startPoint.x, startPoint.y, width, height, rounded, rounded); >+ workImageGC.setBackground(backColor); >+ break; >+ case SelectDrawToolAction.FILL_OVAL: >+ backColor = workImageGC.getBackground(); >+ workImageGC.setBackground(markColor); >+ workImageGC.fillOval(startPoint.x, startPoint.y, width, height); >+ workImageGC.setBackground(backColor); >+ break; >+ case SelectDrawToolAction.TEXT: >+ workImageGC.fillRectangle(startPoint.x, startPoint.y, width, height); >+ workImageGC.drawRectangle(startPoint.x, startPoint.y, width, height); >+ break; >+ } >+ } >+ } > 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 1 Mar 2009 15:39:15 -0000 >@@ -155,6 +155,28 @@ > > 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_RBOX = create(T_TOOL, "edit_rbox.gif"); //$NON-NLS-1$ >+ >+ public static final ImageDescriptor EDIT_OVAL = create(T_TOOL, "edit_oval.gif"); //$NON-NLS-1$ >+ >+ public static final ImageDescriptor EDIT_FILL_BOX = create(T_TOOL, "edit_fill_box.gif"); //$NON-NLS-1$ >+ >+ public static final ImageDescriptor EDIT_FILL_RBOX = create(T_TOOL, "edit_fill_rbox.gif"); //$NON-NLS-1$ >+ >+ public static final ImageDescriptor EDIT_FILL_OVAL = create(T_TOOL, "edit_fill_oval.gif"); //$NON-NLS-1$ >+ >+ public static final ImageDescriptor EDIT_TEXT = create(T_TOOL, "font.gif"); //$NON-NLS-1$ >+ >+ public static final ImageDescriptor EDIT_UNDO = create(T_TOOL, "undo_edit.gif"); //$NON-NLS-1$ >+ >+ public static final ImageDescriptor EDIT_REDO = create(T_TOOL, "redo_edit.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 +223,32 @@ > > 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$ >+ >+ public static final ImageDescriptor LINE_SOLD = create(T_TOOL, "line_sold.gif"); //$NON-NLS-1$ >+ >+ public static final ImageDescriptor LINE_DOT = create(T_TOOL, "line_dot.gif"); //$NON-NLS-1$ >+ >+ public static final ImageDescriptor LINE_DASH = create(T_TOOL, "line_dash.gif"); //$NON-NLS-1$ >+ >+ public static final ImageDescriptor LINE_DASH1D = create(T_TOOL, "line_dash1d.gif"); //$NON-NLS-1$ >+ >+ public static final ImageDescriptor LINE_DASH2D = create(T_TOOL, "line_dash2d.gif"); //$NON-NLS-1$ >+ >+ public static final ImageDescriptor LINE_BOLD1 = create(T_TOOL, "line_bold1.gif"); //$NON-NLS-1$ >+ >+ public static final ImageDescriptor LINE_BOLD2 = create(T_TOOL, "line_bold2.gif"); //$NON-NLS-1$ >+ >+ public static final ImageDescriptor LINE_BOLD4 = create(T_TOOL, "line_bold4.gif"); //$NON-NLS-1$ >+ >+ public static final ImageDescriptor LINE_BOLD8 = create(T_TOOL, "line_bold8.gif"); //$NON-NLS-1$ >+ >+ public static final ImageDescriptor FONT_PROP = create(T_TOOL, "font_props.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.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 1 Mar 2009 15:39:15 -0000 >@@ -15,15 +15,55 @@ > > 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_Change_text_font=Change text font > ScreenshotCreationPage_Clear_all_annotations_made_on_screenshot_image=Clear all annotations made on screenshot image > ScreenshotCreationPage_Clear_Annotations=C&lear Annotations >+ScreenshotCreationPage_Clear=C&lear >+ScreenshotCreationPage_Undo=&Undo >+ScreenshotCreationPage_Undo_annotation=Undo annotation >+ScreenshotCreationPage_Redo=Re&do >+ScreenshotCreationPage_Redo_annotation=Redo annotation > ScreenshotCreationPage_Crop=Crop > ScreenshotCreationPage_Crop_R=C&rop > ScreenshotCreationPage_DRAW_ANNOTATION_ON_SCREENSHOT_IMAGE=Draw annotations on screenshot image > ScreenshotCreationPage_Fit_Image=Fit Image >-ScreenshotCreationPage_Fit_Image_F=&Fit Image >+#ScreenshotCreationPage_Fit_Image_F=&Fit Image >+ScreenshotCreationPage_Fit_Image_F=&Fit >+ScreenshotCreationPage_Font_Bold=, Bold >+ScreenshotCreationPage_Font_Italic=, Italic >+ScreenshotCreationPage_Font_Name_Size={0}, {1} pt > ScreenshotCreationPage_NOTE_THAT_YOU_CONTINUTE=Note that you can continue to interact with the workbench in order to set up the screenshot. >+ >+SelectBoldToolAction_1dot=1 dot >+SelectBoldToolAction_2dots=2 dots >+SelectBoldToolAction_4dots=4 dots >+SelectBoldToolAction_8dots=8 dots >+ >+SelectCaptureAction_Clipboard=Clipboard >+SelectCaptureAction_Desktop=Desktop >+SelectCaptureAction_File=File... >+ >+SelectDrawToolAction_Box=Rectangle >+SelectDrawToolAction_RBox=Round Rectangle >+SelectDrawToolAction_Oval=Oval >+SelectDrawToolAction_FillBox=Fill Rectangle >+SelectDrawToolAction_FillRBox=Fill Round Rectangle >+SelectDrawToolAction_FillOval=Fill Oval >+SelectDrawToolAction_Free=Free >+SelectDrawToolAction_Line=Line >+SelectDrawToolAction_Text=Text >+SelectLineToolAction_Dash=Dashed line >+SelectLineToolAction_Dash_Dot=1 dots dashed line >+SelectLineToolAction_Dash_Dot2=2 dots dashed line >+SelectLineToolAction_Dot=Dotted line >+SelectLineToolAction_Solid=Solid line >+ >+SelectZoomToolAction_Fit=Fit >+SelectZoomToolAction_Zoom1X=100% >+SelectZoomToolAction_Zoom2X=200% >+SelectZoomToolAction_Zoom4X=400% >+SelectZoomToolAction_Zoom8X=800% >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 1 Mar 2009 15:39:15 -0000 >@@ -55,10 +55,22 @@ > > public static String ScreenshotCreationPage_Change_pen_color; > >+ public static String ScreenshotCreationPage_Change_text_font; >+ > public static String ScreenshotCreationPage_Clear_all_annotations_made_on_screenshot_image; > > public static String ScreenshotCreationPage_Clear_Annotations; > >+ public static String ScreenshotCreationPage_Clear; >+ >+ public static String ScreenshotCreationPage_Undo; >+ >+ public static String ScreenshotCreationPage_Undo_annotation; >+ >+ public static String ScreenshotCreationPage_Redo; >+ >+ public static String ScreenshotCreationPage_Redo_annotation; >+ > public static String ScreenshotCreationPage_Crop; > > public static String ScreenshotCreationPage_Crop_R; >@@ -69,5 +81,63 @@ > > public static String ScreenshotCreationPage_Fit_Image_F; > >+ public static String ScreenshotCreationPage_Font_Bold; >+ >+ public static String ScreenshotCreationPage_Font_Italic; >+ >+ public static String ScreenshotCreationPage_Font_Name_Size; >+ > public static String ScreenshotCreationPage_NOTE_THAT_YOU_CONTINUTE; >+ >+ public static String SelectBoldToolAction_1dot; >+ >+ public static String SelectBoldToolAction_2dots; >+ >+ public static String SelectBoldToolAction_4dots; >+ >+ public static String SelectBoldToolAction_8dots; >+ >+ public static String SelectCaptureAction_Clipboard; >+ >+ public static String SelectCaptureAction_Desktop; >+ >+ public static String SelectCaptureAction_File; >+ >+ public static String SelectDrawToolAction_Box; >+ >+ public static String SelectDrawToolAction_RBox; >+ >+ public static String SelectDrawToolAction_Oval; >+ >+ public static String SelectDrawToolAction_FillBox; >+ >+ public static String SelectDrawToolAction_FillRBox; >+ >+ public static String SelectDrawToolAction_FillOval; >+ >+ public static String SelectDrawToolAction_Free; >+ >+ public static String SelectDrawToolAction_Line; >+ >+ public static String SelectDrawToolAction_Text; >+ >+ public static String SelectLineToolAction_Dash; >+ >+ public static String SelectLineToolAction_Dash_Dot; >+ >+ public static String SelectLineToolAction_Dash_Dot2; >+ >+ public static String SelectLineToolAction_Dot; >+ >+ public static String SelectLineToolAction_Solid; >+ >+ public static String SelectZoomToolAction_Fit; >+ >+ public static String SelectZoomToolAction_Zoom1X; >+ >+ public static String SelectZoomToolAction_Zoom2X; >+ >+ public static String SelectZoomToolAction_Zoom4X; >+ >+ public static String SelectZoomToolAction_Zoom8X; > } >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,115 @@ >+package org.eclipse.mylyn.internal.provisional.commons.ui; >+ >+import org.eclipse.jface.action.Action; >+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.FileDialog; >+import org.eclipse.swt.widgets.Shell; >+ >+public class SelectCaptureAction extends SelectToolAction { >+ >+ public static final String ID = "org.eclipse.mylyn.common.ui.actions.selectcapture"; //$NON-NLS-1$ >+ >+ public static final int CAPTURE = 0; >+ >+ public static final int CLIPBOARD = 1; >+ >+ public static final int FILE = 2; >+ >+ private final Shell shell; >+ >+ private String filename; >+ >+ public SelectCaptureAction(Shell shell, String label) { >+ super(label, ID, new int[] { CAPTURE, CLIPBOARD, FILE }, // kinds >+ new String[] { Messages.SelectCaptureAction_Desktop, Messages.SelectCaptureAction_Clipboard, >+ Messages.SelectCaptureAction_File }, // labels >+ new ImageDescriptor[] { CommonImages.MINITOR_OBJ, CommonImages.CLIPBOARD_OBJ, CommonImages.FILE_OBJ }); // images >+ >+ this.shell = shell; >+ } >+ >+ public void resetKind() { >+ reset(CAPTURE); >+ } >+ >+ @Override >+ protected void setKind(String label, ImageDescriptor image) { >+ super.setKind(label, image); >+ >+ if (getKind() == 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; >+ run(); >+ } >+ } else { >+ run(); >+ } >+ } >+ >+ @Override >+ protected void updateLabel(String label, ImageDescriptor image) { >+ } >+ >+ @Override >+ protected void updateAction(Action action, int id) { >+ if (id == CLIPBOARD) { >+ action.setEnabled(existImageOnClipboard()); >+ } >+ } >+ >+ public Image getScreenshotImage() { >+ if (getKind() == CAPTURE) { >+ return null; >+ } >+ >+ if (getKind() == 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/SelectToolAction.java >=================================================================== >RCS file: src/org/eclipse/mylyn/internal/provisional/commons/ui/SelectToolAction.java >diff -N src/org/eclipse/mylyn/internal/provisional/commons/ui/SelectToolAction.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylyn/internal/provisional/commons/ui/SelectToolAction.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,162 @@ >+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.swt.graphics.Point; >+import org.eclipse.swt.graphics.Rectangle; >+import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.Event; >+import org.eclipse.swt.widgets.Menu; >+import org.eclipse.swt.widgets.ToolItem; >+import org.eclipse.swt.widgets.Widget; >+ >+public class SelectToolAction extends Action implements IMenuCreator { >+ >+ private final int[] kinds; >+ >+ private final String[] labels; >+ >+ private final ImageDescriptor[] images; >+ >+ private int kind; >+ >+ private Menu dropDownMenu; >+ >+ private boolean showMenuAlways; >+ >+ public boolean isShowMenuAlways() { >+ return showMenuAlways; >+ } >+ >+ public void setShowMenuAlways(boolean showMenuAlways) { >+ this.showMenuAlways = showMenuAlways; >+ } >+ >+ public SelectToolAction(String label, String ID, int[] kinds, String[] labels, ImageDescriptor[] images) { >+ super(label, AS_DROP_DOWN_MENU); >+ this.kinds = kinds; >+ this.labels = labels; >+ this.images = images; >+ setMenuCreator(this); >+ setId(ID); >+ if (images != null) { >+ setImageDescriptor(images[0]); >+ } >+ setToolTipText(labels[0]); >+ kind = kinds[0]; >+ showMenuAlways = true; >+ } >+ >+ public SelectToolAction(String ID, int[] kinds, String[] labels, ImageDescriptor[] images) { >+ super("", AS_DROP_DOWN_MENU); //$NON-NLS-1$ >+ this.kinds = kinds; >+ this.labels = labels; >+ this.images = images; >+ setMenuCreator(this); >+ setId(ID); >+ if (images != null) { >+ setImageDescriptor(images[0]); >+ } >+ setToolTipText(labels[0]); >+ kind = kinds[0]; >+ showMenuAlways = true; >+ } >+ >+ @Override >+ public void runWithEvent(Event event) { >+ if (showMenuAlways) { >+ IMenuCreator mc = getMenuCreator(); >+ if (mc != null) { >+ Widget item = event.widget; >+ ToolItem ti = (ToolItem) item; >+ Menu m = mc.getMenu(ti.getParent()); >+ if (m != null) { >+ // position the menu below the drop down item >+ Rectangle itemBounds = ti.getBounds(); >+ Point point = ti.getParent().toDisplay(itemBounds.x, itemBounds.y + itemBounds.height); >+ m.setLocation(point.x, point.y); // waiting for SWT >+ m.setVisible(true); >+ return; // we don't fire the action >+ } >+ } >+ } >+ super.runWithEvent(event); >+ } >+ >+ public void reset(int kind) { >+ this.kind = kind; >+ } >+ >+ public int getKind() { >+ return kind; >+ } >+ >+ protected 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]; >+ updateLabel(label, 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]); >+ if (images != null) { >+ action.setImageDescriptor(images[m]); >+ } >+ updateAction(action, kinds[m]); >+ item.fill(dropDownMenu, -1); >+ } >+ } >+ >+ protected void updateAction(Action action, int id) { >+ action.setChecked(id == kind); >+ } >+ >+ protected void updateLabel(String label, ImageDescriptor image) { >+ setToolTipText(label); >+ if (image != null) { >+ setImageDescriptor(image); >+ } >+ } >+ >+ 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()); >+ } >+ } >+} >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,45 @@ >+package org.eclipse.mylyn.internal.provisional.commons.ui; >+ >+import org.eclipse.jface.resource.ImageDescriptor; >+import org.eclipse.mylyn.internal.commons.ui.Messages; >+ >+public class SelectDrawToolAction extends SelectToolAction { >+ >+ public static final String ID = "org.eclipse.mylyn.common.ui.actions.selectdrawtool"; //$NON-NLS-1$ >+ >+ public static final int FREE = 0; >+ >+ public static final int LINE = 1; >+ >+ public static final int BOX = 2; >+ >+ public static final int RBOX = 3; >+ >+ public static final int OVAL = 4; >+ >+ public static final int FILL_BOX = 5; >+ >+ public static final int FILL_RBOX = 6; >+ >+ public static final int FILL_OVAL = 7; >+ >+ public static final int TEXT = 8; >+ >+ public SelectDrawToolAction() { >+ super(ID, new int[] { FREE, LINE, BOX, RBOX, OVAL, FILL_BOX, FILL_RBOX, FILL_OVAL, TEXT }, // kinds >+ new String[] { Messages.SelectDrawToolAction_Free, Messages.SelectDrawToolAction_Line, >+ Messages.SelectDrawToolAction_Box, Messages.SelectDrawToolAction_RBox, >+ Messages.SelectDrawToolAction_Oval, Messages.SelectDrawToolAction_FillBox, >+ Messages.SelectDrawToolAction_FillRBox, Messages.SelectDrawToolAction_FillOval, >+ Messages.SelectDrawToolAction_Text }, // labels >+ new ImageDescriptor[] { CommonImages.EDIT_FREE, CommonImages.EDIT_LINE, CommonImages.EDIT_BOX, >+ CommonImages.EDIT_RBOX, CommonImages.EDIT_OVAL, CommonImages.EDIT_FILL_BOX, >+ CommonImages.EDIT_FILL_RBOX, CommonImages.EDIT_FILL_OVAL, CommonImages.EDIT_TEXT }); // images >+ } >+ >+ @Override >+ protected void setKind(String label, ImageDescriptor image) { >+ super.setKind(label, image); >+ run(); >+ } >+} >Index: src/org/eclipse/mylyn/internal/provisional/commons/ui/SelectLineToolAction.java >=================================================================== >RCS file: src/org/eclipse/mylyn/internal/provisional/commons/ui/SelectLineToolAction.java >diff -N src/org/eclipse/mylyn/internal/provisional/commons/ui/SelectLineToolAction.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylyn/internal/provisional/commons/ui/SelectLineToolAction.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,19 @@ >+package org.eclipse.mylyn.internal.provisional.commons.ui; >+ >+import org.eclipse.jface.resource.ImageDescriptor; >+import org.eclipse.mylyn.internal.commons.ui.Messages; >+import org.eclipse.swt.SWT; >+ >+public class SelectLineToolAction extends SelectToolAction { >+ >+ public static final String ID = "org.eclipse.mylyn.common.ui.actions.selectlinetool"; //$NON-NLS-1$ >+ >+ public SelectLineToolAction() { >+ super(ID, new int[] { SWT.LINE_SOLID, SWT.LINE_DOT, SWT.LINE_DASH, SWT.LINE_DASHDOT, SWT.LINE_DASHDOTDOT }, // kinds >+ new String[] { Messages.SelectLineToolAction_Solid, Messages.SelectLineToolAction_Dot, >+ Messages.SelectLineToolAction_Dash, Messages.SelectLineToolAction_Dash_Dot, >+ Messages.SelectLineToolAction_Dash_Dot2 }, // labels >+ new ImageDescriptor[] { CommonImages.LINE_SOLD, CommonImages.LINE_DOT, CommonImages.LINE_DASH, >+ CommonImages.LINE_DASH1D, CommonImages.LINE_DASH2D }); // images >+ } >+} >Index: src/org/eclipse/mylyn/internal/provisional/commons/ui/SelectZoomToolAction.java >=================================================================== >RCS file: src/org/eclipse/mylyn/internal/provisional/commons/ui/SelectZoomToolAction.java >diff -N src/org/eclipse/mylyn/internal/provisional/commons/ui/SelectZoomToolAction.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylyn/internal/provisional/commons/ui/SelectZoomToolAction.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,38 @@ >+package org.eclipse.mylyn.internal.provisional.commons.ui; >+ >+import org.eclipse.jface.resource.ImageDescriptor; >+import org.eclipse.mylyn.internal.commons.ui.Messages; >+ >+public class SelectZoomToolAction extends SelectToolAction { >+ >+ public static final String ID = "org.eclipse.mylyn.common.ui.actions.selectzoomtool"; //$NON-NLS-1$ >+ >+ public static final int FIT = 0; >+ >+ public static final int ZOOM1X = 1; >+ >+ public static final int ZOOM2X = 2; >+ >+ public static final int ZOOM4X = 3; >+ >+ public static final int ZOOM8X = 4; >+ >+ public SelectZoomToolAction() { >+ super(ID, new int[] { FIT, ZOOM1X, ZOOM2X, ZOOM4X, ZOOM8X }, // kinds >+ new String[] { Messages.SelectZoomToolAction_Fit, Messages.SelectZoomToolAction_Zoom1X, >+ Messages.SelectZoomToolAction_Zoom2X, Messages.SelectZoomToolAction_Zoom4X, >+ Messages.SelectZoomToolAction_Zoom8X }, // labels >+ null); // images >+ } >+ >+ @Override >+ protected void setKind(String label, ImageDescriptor image) { >+ super.setKind(label, image); >+ run(); >+ } >+ >+ @Override >+ protected void updateLabel(String label, ImageDescriptor image) { >+ setText(label); >+ } >+} >Index: src/org/eclipse/mylyn/internal/provisional/commons/ui/SelectBoldToolAction.java >=================================================================== >RCS file: src/org/eclipse/mylyn/internal/provisional/commons/ui/SelectBoldToolAction.java >diff -N src/org/eclipse/mylyn/internal/provisional/commons/ui/SelectBoldToolAction.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/mylyn/internal/provisional/commons/ui/SelectBoldToolAction.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,18 @@ >+package org.eclipse.mylyn.internal.provisional.commons.ui; >+ >+import org.eclipse.jface.resource.ImageDescriptor; >+import org.eclipse.mylyn.internal.commons.ui.Messages; >+ >+public class SelectBoldToolAction extends SelectToolAction { >+ >+ public static final String ID = "org.eclipse.mylyn.common.ui.actions.selectboldtool"; //$NON-NLS-1$ >+ >+ public SelectBoldToolAction() { >+ super(ID, new int[] { 1, 2, 4, 8 }, // kinds >+ new String[] { Messages.SelectBoldToolAction_1dot, Messages.SelectBoldToolAction_2dots, >+ Messages.SelectBoldToolAction_4dots, Messages.SelectBoldToolAction_8dots }, // labels >+ new ImageDescriptor[] { CommonImages.LINE_BOLD1, CommonImages.LINE_BOLD2, CommonImages.LINE_BOLD4, >+ CommonImages.LINE_BOLD8 }); // images >+ setKind(Messages.SelectBoldToolAction_4dots, CommonImages.LINE_BOLD4); >+ } >+}
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