/** * Handles clicks within the preview (x and y are positions relative within the preview * * @param x the x coordinate within the preview where the click occurred * @param y the y coordinate within the preview where the click occurred * @return true if this preview handled (and therefore consumed) the click */ public boolean click(int x, int y) { if (y >= mTitleHeight && y < mTitleHeight + HEADER_HEIGHT) { int left = 0; left += CLOSE_ICON_WIDTH; if (x <= left) { // Delete mManager.deletePreview(this); return true; } left += ZOOM_IN_ICON_WIDTH; if (x <= left) { // Zoom in mScale = mScale * (1 / 0.5); if (Math.abs(mScale - 1.0) < 0.0001) { mScale = 1.0; } render(0); mManager.layout(true); mCanvas.redraw(); return true; } left += ZOOM_OUT_ICON_WIDTH; if (x <= left) { // Zoom out mScale = mScale * (0.5 / 1); if (Math.abs(mScale - 1.0) < 0.0001) { mScale = 1.0; } render(0); mManager.layout(true); mCanvas.redraw(); return true; } left += EDIT_ICON_WIDTH; if (x <= left) { // Edit. For now, just rename InputDialog d = new InputDialog( AdtPlugin.getShell(), "Rename Preview", // title "Name:", getDisplayName(), null); if (d.open() == Window.OK) { String newName = d.getValue(); mConfiguration.setDisplayName(newName); if (mDescription != null) { mManager.rename(mDescription, newName); } mCanvas.redraw(); } return true; } // Clicked anywhere else on header // Perhaps open Edit dialog here? } mManager.switchTo(this); return true; }