From e27f9f9d577ae7645fe087a72ed0e3dc8717892e Mon Sep 17 00:00:00 2001 From: Bruno Sinou Date: Fri, 20 Nov 2015 17:50:42 +0000 Subject: [PATCH] Factorize widely use pattern to check strings in UI implementation git-svn-id: https://svn.argeo.org/commons/trunk@8578 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- .../org/argeo/eclipse/ui/EclipseUiUtils.java | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) 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 36b8e3459..fad0e0df9 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 @@ -66,7 +66,7 @@ public class EclipseUiUtils { .setStyle(SWT.BOLD | SWT.ITALIC) .createFont(parent.getDisplay()); } - + // // Simplify grid layouts management // @@ -176,6 +176,15 @@ public class EclipseUiUtils { * Create a label and a text field with password display for a grid layout, * the text field grabbing excess horizontal */ + public static Text createGridLP(Composite parent, String label) { + return createGridLP(parent, label, null); + } + + /** + * Create a label and a text field with password display for a grid layout, + * the text field grabbing excess horizontal. The given modify listener will + * be added to the newly created text field if not null. + */ public static Text createGridLP(Composite parent, String label, ModifyListener modifyListener) { Label lbl = new Label(parent, SWT.LEAD); @@ -188,4 +197,15 @@ public class EclipseUiUtils { return txt; } + // MISCELLANEOUS + + /** Simply checks if a string is not null nor empty */ + public static boolean notEmpty(String stringToTest) { + return !(stringToTest == null || "".equals(stringToTest.trim())); + } + + /** Simply checks if a string is null or empty */ + public static boolean isEmpty(String stringToTest) { + return stringToTest == null || "".equals(stringToTest.trim()); + } } \ No newline at end of file -- 2.30.2