X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.eclipse.ui%2Fsrc%2Forg%2Fargeo%2Feclipse%2Fui%2FEclipseUiUtils.java;h=2a17d285cc106835022597545ec5a13e6840e92e;hb=9026a86b983ee8d99ce90a88c78d6d37d7877eec;hp=8e1c7e63210cd34b75caff9b901d6f9bdf0585ec;hpb=e61dd9dda88354091625cca85aa7c96d196688b3;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.eclipse.ui/src/org/argeo/eclipse/ui/EclipseUiUtils.java b/org.argeo.eclipse.ui/src/org/argeo/eclipse/ui/EclipseUiUtils.java index 8e1c7e632..2a17d285c 100644 --- a/org.argeo.eclipse.ui/src/org/argeo/eclipse/ui/EclipseUiUtils.java +++ b/org.argeo.eclipse.ui/src/org/argeo/eclipse/ui/EclipseUiUtils.java @@ -19,21 +19,71 @@ import org.eclipse.jface.resource.JFaceResources; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.layout.FormAttachment; +import org.eclipse.swt.layout.FormData; import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; /** Utilities to simplify UI development. */ public class EclipseUiUtils { + + // + // Simplify grid layouts management + // + public static GridLayout noSpaceGridLayout() { + return noSpaceGridLayout(new GridLayout()); + } + + public static GridLayout noSpaceGridLayout(GridLayout layout) { + layout.horizontalSpacing = 0; + layout.verticalSpacing = 0; + layout.marginWidth = 0; + layout.marginHeight = 0; + return layout; + } + + public static GridData fillWidth() { + return grabWidth(SWT.FILL, SWT.FILL); + } + + public static GridData fillAll() { + return new GridData(SWT.FILL, SWT.FILL, true, true); + } + + public static GridData grabWidth(int horizontalAlignment, + int verticalAlignment) { + return new GridData(horizontalAlignment, horizontalAlignment, true, + false); + } + + // + // Simplify Form layout management + // + /** - * Create a label and a text field for a grid layout, the text field grabing - * excess horizontal + * Creates a basic form data that is attached to the 4 corners of the parent + * composite + */ + public static FormData fillFormData() { + FormData formData = new FormData(); + formData.top = new FormAttachment(0, 0); + formData.left = new FormAttachment(0, 0); + formData.right = new FormAttachment(100, 0); + formData.bottom = new FormAttachment(100, 0); + return formData; + } + + /** + * Create a label and a text field for a grid layout, the text field + * grabbing excess horizontal * * @param parent * the parent composite * @param label - * the lable to display + * the label to display * @param modifyListener * a {@link ModifyListener} to listen on events on the text, can * be null @@ -64,7 +114,7 @@ public class EclipseUiUtils { } /** - * Creates one label and a text field not editable with background color of + * Creates one label and a text field not editable with background colour of * the parent (like a label but with selectable text) */ public static Text createGridLL(Composite parent, String label, String text) { @@ -91,6 +141,10 @@ public class EclipseUiUtils { return txt; } + // + // FONTS + // + /** Shortcut to retrieve default italic font from display */ public static Font getItalicFont(Composite parent) { return JFaceResources.getFontRegistry().defaultFontDescriptor()