]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - org.argeo.eclipse.ui/src/org/argeo/eclipse/ui/EclipseUiUtils.java
Simplify column viewer comparator in order to make it more portable
[lgpl/argeo-commons.git] / org.argeo.eclipse.ui / src / org / argeo / eclipse / ui / EclipseUiUtils.java
index f3979d074e94fbd77f8f79e646ab4ca3395b634b..fad0e0df9910208a0ad1599a85e6459c6334a3bd 100644 (file)
@@ -37,6 +37,36 @@ public class EclipseUiUtils {
                        child.dispose();
        }
 
+       /**
+        * Enables efficient call to the layout method of a composite, refreshing
+        * only some of the children controls.
+        */
+       public static void layout(Composite parent, Control... toUpdateControls) {
+               parent.layout(toUpdateControls);
+       }
+
+       //
+       // FONTS
+       //
+       /** Shortcut to retrieve default italic font from display */
+       public static Font getItalicFont(Composite parent) {
+               return JFaceResources.getFontRegistry().defaultFontDescriptor()
+                               .setStyle(SWT.ITALIC).createFont(parent.getDisplay());
+       }
+
+       /** Shortcut to retrieve default bold font from display */
+       public static Font getBoldFont(Composite parent) {
+               return JFaceResources.getFontRegistry().defaultFontDescriptor()
+                               .setStyle(SWT.BOLD).createFont(parent.getDisplay());
+       }
+
+       /** Shortcut to retrieve default bold italic font from display */
+       public static Font getBoldItalicFont(Composite parent) {
+               return JFaceResources.getFontRegistry().defaultFontDescriptor()
+                               .setStyle(SWT.BOLD | SWT.ITALIC)
+                               .createFont(parent.getDisplay());
+       }
+
        //
        // Simplify grid layouts management
        //
@@ -146,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);
@@ -158,26 +197,15 @@ public class EclipseUiUtils {
                return txt;
        }
 
-       //
-       // FONTS
-       //
-
-       /** Shortcut to retrieve default italic font from display */
-       public static Font getItalicFont(Composite parent) {
-               return JFaceResources.getFontRegistry().defaultFontDescriptor()
-                               .setStyle(SWT.ITALIC).createFont(parent.getDisplay());
-       }
+       // MISCELLANEOUS
 
-       /** Shortcut to retrieve default bold font from display */
-       public static Font getBoldFont(Composite parent) {
-               return JFaceResources.getFontRegistry().defaultFontDescriptor()
-                               .setStyle(SWT.BOLD).createFont(parent.getDisplay());
+       /** Simply checks if a string is not null nor empty */
+       public static boolean notEmpty(String stringToTest) {
+               return !(stringToTest == null || "".equals(stringToTest.trim()));
        }
 
-       /** Shortcut to retrieve default bold italic font from display */
-       public static Font getBoldItalicFont(Composite parent) {
-               return JFaceResources.getFontRegistry().defaultFontDescriptor()
-                               .setStyle(SWT.BOLD | SWT.ITALIC)
-                               .createFont(parent.getDisplay());
+       /** 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