Factorize widely use pattern to check strings in UI implementation
authorBruno Sinou <bsinou@argeo.org>
Fri, 20 Nov 2015 17:50:42 +0000 (17:50 +0000)
committerBruno Sinou <bsinou@argeo.org>
Fri, 20 Nov 2015 17:50:42 +0000 (17:50 +0000)
git-svn-id: https://svn.argeo.org/commons/trunk@8578 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

org.argeo.eclipse.ui/src/org/argeo/eclipse/ui/EclipseUiUtils.java

index 36b8e345976c703297c4ed3984c511e590ff231a..fad0e0df9910208a0ad1599a85e6459c6334a3bd 100644 (file)
@@ -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