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 117024 Details for
Bug 253798
[JFace] SWTUtil challenges PixelConverter for party animal status
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
proposed changes
patch253798.txt (text/plain), 6.16 KB, created by
Susan McCourt
on 2008-11-04 19:05:58 EST
(
hide
)
Description:
proposed changes
Filename:
MIME Type:
Creator:
Susan McCourt
Created:
2008-11-04 19:05:58 EST
Size:
6.16 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jface >Index: src/org/eclipse/jface/util/Util.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jface/src/org/eclipse/jface/util/Util.java,v >retrieving revision 1.14 >diff -u -r1.14 Util.java >--- src/org/eclipse/jface/util/Util.java 1 Oct 2008 15:36:19 -0000 1.14 >+++ src/org/eclipse/jface/util/Util.java 5 Nov 2008 00:05:23 -0000 >@@ -19,6 +19,15 @@ > import java.util.TreeSet; > > import org.eclipse.swt.SWT; >+import org.eclipse.swt.dnd.DragSource; >+import org.eclipse.swt.dnd.DropTarget; >+import org.eclipse.swt.widgets.Caret; >+import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.Display; >+import org.eclipse.swt.widgets.Menu; >+import org.eclipse.swt.widgets.ScrollBar; >+import org.eclipse.swt.widgets.Shell; >+import org.eclipse.swt.widgets.Widget; > > /** > * <p> >@@ -657,4 +666,51 @@ > private Util() { > // Not allowed. > } >+ >+ // Methods for working with individual widgets or controls >+ >+ /** >+ * Returns the shell for the given widget. If the widget doesn't represent >+ * an SWT object that has a shell, return <code>null</code>. >+ * @param widget the widget >+ * @return the shell for the given widget, or <code>null</code> if there >+ * is no shell associated with the widget. >+ * >+ * @since 3.5 >+ */ >+ public static final Shell getShell(Widget widget) { >+ if (widget instanceof Control) >+ return ((Control) widget).getShell(); >+ if (widget instanceof Caret) >+ return ((Caret) widget).getParent().getShell(); >+ if (widget instanceof DragSource) >+ return ((DragSource) widget).getControl().getShell(); >+ if (widget instanceof DropTarget) >+ return ((DropTarget) widget).getControl().getShell(); >+ if (widget instanceof Menu) >+ return ((Menu) widget).getParent().getShell(); >+ if (widget instanceof ScrollBar) >+ return ((ScrollBar) widget).getParent().getShell(); >+ >+ return null; >+ } >+ >+ /** >+ * Returns a suitable display for the caller. This method may be called from >+ * a non-UI thread. >+ * >+ * This method first checks if the thread calling this method has a display. >+ * If not, then this method returns the default display. >+ * >+ * @return the display appropriate for the calling thread >+ * >+ * @since 3.5 >+ */ >+ public static Display getStandardDisplay() { >+ Display display; >+ display = Display.getCurrent(); >+ if (display == null) >+ display = Display.getDefault(); >+ return display; >+ } > } >Index: src/org/eclipse/jface/dialogs/Dialog.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jface/src/org/eclipse/jface/dialogs/Dialog.java,v >retrieving revision 1.69 >diff -u -r1.69 Dialog.java >--- src/org/eclipse/jface/dialogs/Dialog.java 1 Oct 2008 15:36:18 -0000 1.69 >+++ src/org/eclipse/jface/dialogs/Dialog.java 5 Nov 2008 00:05:23 -0000 >@@ -412,6 +412,24 @@ > // No default behaviour > } > }; >+ >+ /** >+ * Set the size of the specified dialog's shell so that the height and width >+ * are no smaller than the sizes specified. The size may be larger if the >+ * default computed size is larger. >+ * >+ * @param dialog the dialog >+ * @param width the minimum width of the dialog >+ * @param height the minimum height of the dialog >+ * >+ * @since 3.5 >+ */ >+ public static void setMinimumDialogSize(Dialog dialog, int width, int height) { >+ Point computedSize = dialog.getShell().computeSize(SWT.DEFAULT, SWT.DEFAULT); >+ width = Math.max(computedSize.x, width); >+ height = Math.max(computedSize.y, height); >+ dialog.getShell().setSize(width, height); >+ } > > /** > * Creates a dialog instance. Note that the window will have no visual >Index: src/org/eclipse/jface/layout/LayoutUtils.java >=================================================================== >RCS file: src/org/eclipse/jface/layout/LayoutUtils.java >diff -N src/org/eclipse/jface/layout/LayoutUtils.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jface/layout/LayoutUtils.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,56 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jface.layout; >+ >+ >+import org.eclipse.core.runtime.Assert; >+import org.eclipse.jface.dialogs.IDialogConstants; >+import org.eclipse.jface.resource.JFaceResources; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.widgets.Button; >+ >+/** >+ * LayoutUtils provides commonly needed calculations for determining >+ * the size and/or location of controls, according to JFace conventions. >+ * >+ * @since 3.5 >+ */ >+public class LayoutUtils { >+ >+ /** >+ * Returns a width hint for a button control. >+ * @param button the button >+ * @return the width hint >+ */ >+ public static int getButtonWidthHint(Button button) { >+ button.setFont(JFaceResources.getDialogFont()); >+ PixelConverter converter= new PixelConverter(button); >+ int widthHint= converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); >+ return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); >+ } >+ >+ /** >+ * Sets the appropriate width and height hint for the button control >+ * into the specified grid data, and sets this grid data as the button's >+ * layout data. >+ * >+ * @param button the button for which to set the dimension hint >+ * @param data the grid data to use for the button >+ */ >+ public static void setButtonDimensionHint(Button button, GridData data) { >+ Assert.isNotNull(button); >+ Assert.isNotNull(data); >+ data.widthHint = getButtonWidthHint(button); >+ data.horizontalAlignment = GridData.FILL; >+ button.setLayoutData(data); >+ } >+}
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 253798
: 117024