]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - org.argeo.eclipse.ui/src/org/argeo/eclipse/ui/EclipseUiUtils.java
Small UI enhancements
[lgpl/argeo-commons.git] / org.argeo.eclipse.ui / src / org / argeo / eclipse / ui / EclipseUiUtils.java
index 2a17d285cc106835022597545ec5a13e6840e92e..f3979d074e94fbd77f8f79e646ab4ca3395b634b 100644 (file)
@@ -24,12 +24,19 @@ 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.Control;
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Text;
 
 /** Utilities to simplify UI development. */
 public class EclipseUiUtils {
 
+       /** Dispose all children of a Composite */
+       public static void clear(Composite composite) {
+               for (Control child : composite.getChildren())
+                       child.dispose();
+       }
+
        //
        // Simplify grid layouts management
        //
@@ -49,10 +56,20 @@ public class EclipseUiUtils {
                return grabWidth(SWT.FILL, SWT.FILL);
        }
 
+       public static GridData fillWidth(int colSpan) {
+               GridData gd = grabWidth(SWT.FILL, SWT.FILL);
+               gd.horizontalSpan = colSpan;
+               return gd;
+       }
+
        public static GridData fillAll() {
                return new GridData(SWT.FILL, SWT.FILL, true, true);
        }
 
+       public static GridData fillAll(int colSpan, int rowSpan) {
+               return new GridData(SWT.FILL, SWT.FILL, true, true, colSpan, rowSpan);
+       }
+
        public static GridData grabWidth(int horizontalAlignment,
                        int verticalAlignment) {
                return new GridData(horizontalAlignment, horizontalAlignment, true,
@@ -136,7 +153,7 @@ public class EclipseUiUtils {
                lbl.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
                Text txt = new Text(parent, SWT.LEAD | SWT.BORDER | SWT.PASSWORD);
                txt.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
-               if (txt != null)
+               if (modifyListener != null)
                        txt.addModifyListener(modifyListener);
                return txt;
        }