You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2015/04/22 18:33:50 UTC

svn commit: r1675407 - in /directory/studio/trunk/plugins/common.ui: resources/icons/ src/main/java/org/apache/directory/studio/common/ui/ src/main/java/org/apache/directory/studio/common/ui/widgets/

Author: elecharny
Date: Wed Apr 22 16:33:50 2015
New Revision: 1675407

URL: http://svn.apache.org/r1675407
Log:
o Create the Colors in the COmmonUIPlugin, and dispose them there too.
o Added a set of createIntegerText() helper methods, to be used by the other plugins.

Added:
    directory/studio/trunk/plugins/common.ui/resources/icons/information.gif   (with props)
Modified:
    directory/studio/trunk/plugins/common.ui/src/main/java/org/apache/directory/studio/common/ui/CommonUIConstants.java
    directory/studio/trunk/plugins/common.ui/src/main/java/org/apache/directory/studio/common/ui/CommonUIPlugin.java
    directory/studio/trunk/plugins/common.ui/src/main/java/org/apache/directory/studio/common/ui/widgets/BaseWidgetUtils.java

Added: directory/studio/trunk/plugins/common.ui/resources/icons/information.gif
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/common.ui/resources/icons/information.gif?rev=1675407&view=auto
==============================================================================
Binary file - no diff available.

Propchange: directory/studio/trunk/plugins/common.ui/resources/icons/information.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: directory/studio/trunk/plugins/common.ui/src/main/java/org/apache/directory/studio/common/ui/CommonUIConstants.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/common.ui/src/main/java/org/apache/directory/studio/common/ui/CommonUIConstants.java?rev=1675407&r1=1675406&r2=1675407&view=diff
==============================================================================
--- directory/studio/trunk/plugins/common.ui/src/main/java/org/apache/directory/studio/common/ui/CommonUIConstants.java (original)
+++ directory/studio/trunk/plugins/common.ui/src/main/java/org/apache/directory/studio/common/ui/CommonUIConstants.java Wed Apr 22 16:33:50 2015
@@ -20,6 +20,7 @@
 
 package org.apache.directory.studio.common.ui;
 
+import org.eclipse.swt.graphics.Color;
 import org.eclipse.swt.graphics.RGB;
 
 
@@ -61,9 +62,11 @@ public final class CommonUIConstants
      * <li>255 : Full color ([color]), for instance GREEN</li>
      * </ul>
      **/
-    // To see teh world in black and white
+    // To see the world in black and white
     public static final RGB BLACK = new RGB( 0, 0, 0 );
+    public static Color BLACK_COLOR;
     public static final RGB WHITE = new RGB( 255, 255, 255 );
+    public static Color WHITE_COLOR;
     
     // 7 shade of greys... From dark to light, with combinaisons
     public static final RGB BD_GREY = new RGB( 32, 32, 32 );    // Black Dark grey
@@ -89,5 +92,5 @@ public final class CommonUIConstants
     public static final RGB BLUE = new RGB( 0, 0, 255 );        // Full blue
     
     // Some specific colors
-    
+    public static final String IMG_INFORMATION = "resources/icons/information.gif"; //$NON-NLS-1$
 }

Modified: directory/studio/trunk/plugins/common.ui/src/main/java/org/apache/directory/studio/common/ui/CommonUIPlugin.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/common.ui/src/main/java/org/apache/directory/studio/common/ui/CommonUIPlugin.java?rev=1675407&r1=1675406&r2=1675407&view=diff
==============================================================================
--- directory/studio/trunk/plugins/common.ui/src/main/java/org/apache/directory/studio/common/ui/CommonUIPlugin.java (original)
+++ directory/studio/trunk/plugins/common.ui/src/main/java/org/apache/directory/studio/common/ui/CommonUIPlugin.java Wed Apr 22 16:33:50 2015
@@ -29,6 +29,7 @@ import org.eclipse.core.runtime.FileLoca
 import org.eclipse.core.runtime.Path;
 import org.eclipse.core.runtime.Status;
 import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.Color;
 import org.eclipse.swt.graphics.Image;
 import org.eclipse.ui.plugin.AbstractUIPlugin;
 import org.osgi.framework.BundleContext;
@@ -61,15 +62,24 @@ public class CommonUIPlugin extends Abst
     public void start( BundleContext context ) throws Exception
     {
         super.start( context );
+        
+        // Create the colors we use
+        CommonUIConstants.BLACK_COLOR = new Color( null, CommonUIConstants.BLACK );
+        CommonUIConstants.WHITE_COLOR = new Color( null, CommonUIConstants.WHITE );
     }
 
 
     /**
-     * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+     * @see AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
      */
     public void stop( BundleContext context ) throws Exception
     {
         plugin = null;
+        
+        // Dispose the colors
+        CommonUIConstants.BLACK_COLOR.dispose();
+        CommonUIConstants.WHITE_COLOR.dispose();
+
         super.stop( context );
     }
 

Modified: directory/studio/trunk/plugins/common.ui/src/main/java/org/apache/directory/studio/common/ui/widgets/BaseWidgetUtils.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/plugins/common.ui/src/main/java/org/apache/directory/studio/common/ui/widgets/BaseWidgetUtils.java?rev=1675407&r1=1675406&r2=1675407&view=diff
==============================================================================
--- directory/studio/trunk/plugins/common.ui/src/main/java/org/apache/directory/studio/common/ui/widgets/BaseWidgetUtils.java (original)
+++ directory/studio/trunk/plugins/common.ui/src/main/java/org/apache/directory/studio/common/ui/widgets/BaseWidgetUtils.java Wed Apr 22 16:33:50 2015
@@ -21,10 +21,16 @@
 package org.apache.directory.studio.common.ui.widgets;
 
 
+import org.apache.directory.studio.common.ui.CommonUIConstants;
+import org.apache.directory.studio.common.ui.CommonUIPlugin;
+import org.eclipse.ui.forms.widgets.FormToolkit;
 import org.eclipse.jface.dialogs.Dialog;
 import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.fieldassist.ControlDecoration;
 import org.eclipse.jface.resource.JFaceResources;
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.VerifyEvent;
+import org.eclipse.swt.events.VerifyListener;
 import org.eclipse.swt.graphics.FontMetrics;
 import org.eclipse.swt.graphics.GC;
 import org.eclipse.swt.layout.GridData;
@@ -45,7 +51,6 @@ import org.eclipse.swt.widgets.Text;
  */
 public class BaseWidgetUtils
 {
-
     /**
      * Creates a SWT {@link Group} under the given parent.
      *
@@ -57,11 +62,12 @@ public class BaseWidgetUtils
     public static Group createGroup( Composite parent, String label, int span )
     {
         Group group = new Group( parent, SWT.NONE );
-        GridData gd = new GridData( GridData.FILL_BOTH );
-        gd.horizontalSpan = span;
-        group.setLayoutData( gd );
+        GridData gridData = new GridData( GridData.FILL_BOTH );
+        gridData.horizontalSpan = span;
+        group.setLayoutData( gridData );
         group.setText( label );
         group.setLayout( new GridLayout() );
+        
         return group;
     }
 
@@ -95,12 +101,13 @@ public class BaseWidgetUtils
         int span )
     {
         Composite container = new Composite( parent, SWT.NONE );
-        GridLayout gl = new GridLayout( columnCount, makeColumnsEqualWidth );
-        gl.marginHeight = gl.marginWidth = 0;
-        container.setLayout( gl );
-        GridData gd = new GridData( GridData.FILL_HORIZONTAL );
-        gd.horizontalSpan = span;
-        container.setLayoutData( gd );
+        GridLayout gridLayout = new GridLayout( columnCount, makeColumnsEqualWidth );
+        gridLayout.marginHeight = gridLayout.marginWidth = 0;
+        container.setLayout( gridLayout );
+        GridData gridData = new GridData( GridData.FILL_HORIZONTAL );
+        gridData.horizontalSpan = span;
+        container.setLayoutData( gridData );
+        
         return container;
     }
 
@@ -115,13 +122,13 @@ public class BaseWidgetUtils
      */
     public static Label createLabel( Composite parent, String text, int span )
     {
-        Label l = new Label( parent, SWT.NONE );
-        GridData gd = new GridData();
-        gd.horizontalSpan = span;
-        // gd.verticalAlignment = SWT.BEGINNING;
-        l.setLayoutData( gd );
-        l.setText( text );
-        return l;
+        Label label = new Label( parent, SWT.NONE );
+        GridData gridData = new GridData();
+        gridData.horizontalSpan = span;
+        label.setLayoutData( gridData );
+        label.setText( text );
+        
+        return label;
     }
 
 
@@ -136,13 +143,14 @@ public class BaseWidgetUtils
      */
     public static Label createWrappedLabel( Composite parent, String text, int span )
     {
-        Label l = new Label( parent, SWT.WRAP );
-        GridData gd = new GridData( GridData.FILL_HORIZONTAL );
-        gd.horizontalSpan = span;
-        gd.widthHint = 100;
-        l.setLayoutData( gd );
-        l.setText( text );
-        return l;
+        Label label = new Label( parent, SWT.WRAP );
+        GridData gridData = new GridData( GridData.FILL_HORIZONTAL );
+        gridData.horizontalSpan = span;
+        gridData.widthHint = 100;
+        label.setLayoutData( gridData );
+        label.setText( text );
+        
+        return label;
     }
 
 
@@ -157,12 +165,13 @@ public class BaseWidgetUtils
      */
     public static Text createText( Composite parent, String text, int span )
     {
-        Text t = new Text( parent, SWT.NONE | SWT.BORDER );
-        GridData gd = new GridData( GridData.FILL_HORIZONTAL );
-        gd.horizontalSpan = span;
-        t.setLayoutData( gd );
-        t.setText( text );
-        return t;
+        Text textWidget = new Text( parent, SWT.NONE | SWT.BORDER );
+        GridData gridData = new GridData( GridData.FILL_HORIZONTAL );
+        gridData.horizontalSpan = span;
+        textWidget.setLayoutData( gridData );
+        textWidget.setText( text );
+        
+        return textWidget;
     }
 
 
@@ -178,14 +187,15 @@ public class BaseWidgetUtils
      */
     public static Text createText( Composite parent, String text, int textWidth, int span )
     {
-        Text t = new Text( parent, SWT.NONE | SWT.BORDER );
-        GridData gd = new GridData();
-        gd.horizontalSpan = span;
-        gd.widthHint = 9 * textWidth;
-        t.setLayoutData( gd );
-        t.setText( text );
-        t.setTextLimit( textWidth );
-        return t;
+        Text textWidget = new Text( parent, SWT.NONE | SWT.BORDER );
+        GridData gridData = new GridData();
+        gridData.horizontalSpan = span;
+        gridData.widthHint = 9 * textWidth;
+        textWidget.setLayoutData( gridData );
+        textWidget.setText( text );
+        textWidget.setTextLimit( textWidth );
+        
+        return textWidget;
     }
 
 
@@ -200,12 +210,13 @@ public class BaseWidgetUtils
      */
     public static Text createPasswordText( Composite parent, String text, int span )
     {
-        Text t = new Text( parent, SWT.NONE | SWT.BORDER | SWT.PASSWORD );
-        GridData gd = new GridData( GridData.FILL_HORIZONTAL );
-        gd.horizontalSpan = span;
-        t.setLayoutData( gd );
-        t.setText( text );
-        return t;
+        Text textWidget = new Text( parent, SWT.NONE | SWT.BORDER | SWT.PASSWORD );
+        GridData gridData = new GridData( GridData.FILL_HORIZONTAL );
+        gridData.horizontalSpan = span;
+        textWidget.setLayoutData( gridData );
+        textWidget.setText( text );
+        
+        return textWidget;
     }
 
 
@@ -221,14 +232,15 @@ public class BaseWidgetUtils
      */
     public static Text createReadonlyPasswordText( Composite parent, String text, int span )
     {
-        Text t = new Text( parent, SWT.NONE | SWT.BORDER | SWT.PASSWORD | SWT.READ_ONLY );
-        GridData gd = new GridData( GridData.FILL_HORIZONTAL );
-        gd.horizontalSpan = span;
-        t.setLayoutData( gd );
-        t.setEditable( false );
-        t.setBackground( parent.getBackground() );
-        t.setText( text );
-        return t;
+        Text textWidget = new Text( parent, SWT.NONE | SWT.BORDER | SWT.PASSWORD | SWT.READ_ONLY );
+        GridData gridData = new GridData( GridData.FILL_HORIZONTAL );
+        gridData.horizontalSpan = span;
+        textWidget.setLayoutData( gridData );
+        textWidget.setEditable( false );
+        textWidget.setBackground( parent.getBackground() );
+        textWidget.setText( text );
+        
+        return textWidget;
     }
 
 
@@ -245,14 +257,15 @@ public class BaseWidgetUtils
      */
     public static Text createLabeledText( Composite parent, String text, int span )
     {
-        Text t = new Text( parent, SWT.NONE );
-        GridData gd = new GridData( GridData.FILL_HORIZONTAL );
-        gd.horizontalSpan = span;
-        t.setLayoutData( gd );
-        t.setEditable( false );
-        t.setBackground( parent.getBackground() );
-        t.setText( text );
-        return t;
+        Text textWidget = new Text( parent, SWT.NONE );
+        GridData gridData = new GridData( GridData.FILL_HORIZONTAL );
+        gridData.horizontalSpan = span;
+        textWidget.setLayoutData( gridData );
+        textWidget.setEditable( false );
+        textWidget.setBackground( parent.getBackground() );
+        textWidget.setText( text );
+        
+        return textWidget;
     }
 
 
@@ -270,15 +283,16 @@ public class BaseWidgetUtils
      */
     public static Text createLabeledText( Composite parent, String text, int span, int widthHint )
     {
-        Text t = new Text( parent, SWT.NONE );
-        GridData gd = new GridData( SWT.FILL, SWT.NONE, true, false );
-        gd.horizontalSpan = span;
-        gd.widthHint = widthHint;
-        t.setLayoutData( gd );
-        t.setEditable( false );
-        t.setBackground( parent.getBackground() );
-        t.setText( text );
-        return t;
+        Text textWidget = new Text( parent, SWT.NONE );
+        GridData gridData = new GridData( SWT.FILL, SWT.NONE, true, false );
+        gridData.horizontalSpan = span;
+        gridData.widthHint = widthHint;
+        textWidget.setLayoutData( gridData );
+        textWidget.setEditable( false );
+        textWidget.setBackground( parent.getBackground() );
+        textWidget.setText( text );
+        
+        return textWidget;
     }
 
 
@@ -296,17 +310,18 @@ public class BaseWidgetUtils
      */
     public static Text createWrappedLabeledText( Composite parent, String text, int span )
     {
-        Text t = new Text( parent, SWT.WRAP );
-        GridData gd = new GridData( GridData.FILL_HORIZONTAL );
-        gd.horizontalSpan = span;
-        gd.widthHint = 10;
-        gd.grabExcessHorizontalSpace = true;
-        gd.horizontalAlignment = GridData.FILL;
-        t.setLayoutData( gd );
-        t.setEditable( false );
-        t.setBackground( parent.getBackground() );
-        t.setText( text );
-        return t;
+        Text textWidget = new Text( parent, SWT.WRAP );
+        GridData gridData = new GridData( GridData.FILL_HORIZONTAL );
+        gridData.horizontalSpan = span;
+        gridData.widthHint = 10;
+        gridData.grabExcessHorizontalSpace = true;
+        gridData.horizontalAlignment = GridData.FILL;
+        textWidget.setLayoutData( gridData );
+        textWidget.setEditable( false );
+        textWidget.setBackground( parent.getBackground() );
+        textWidget.setText( text );
+        
+        return textWidget;
     }
 
 
@@ -325,17 +340,18 @@ public class BaseWidgetUtils
      */
     public static Text createWrappedLabeledText( Composite parent, String text, int span, int widthHint )
     {
-        Text t = new Text( parent, SWT.WRAP );
-        GridData gd = new GridData( GridData.FILL_HORIZONTAL );
-        gd.horizontalSpan = span;
-        gd.widthHint = widthHint;
-        gd.grabExcessHorizontalSpace = true;
-        gd.horizontalAlignment = GridData.FILL;
-        t.setLayoutData( gd );
-        t.setEditable( false );
-        t.setBackground( parent.getBackground() );
-        t.setText( text );
-        return t;
+        Text textWidget = new Text( parent, SWT.WRAP );
+        GridData gridData = new GridData( GridData.FILL_HORIZONTAL );
+        gridData.horizontalSpan = span;
+        gridData.widthHint = widthHint;
+        gridData.grabExcessHorizontalSpace = true;
+        gridData.horizontalAlignment = GridData.FILL;
+        textWidget.setLayoutData( gridData );
+        textWidget.setEditable( false );
+        textWidget.setBackground( parent.getBackground() );
+        textWidget.setText( text );
+        
+        return textWidget;
     }
 
 
@@ -351,14 +367,15 @@ public class BaseWidgetUtils
      */
     public static Text createReadonlyText( Composite parent, String text, int span )
     {
-        Text t = new Text( parent, SWT.NONE | SWT.BORDER | SWT.READ_ONLY );
-        GridData gd = new GridData( GridData.FILL_HORIZONTAL );
-        gd.horizontalSpan = span;
-        t.setLayoutData( gd );
-        t.setEditable( false );
-        t.setBackground( parent.getBackground() );
-        t.setText( text );
-        return t;
+        Text textWidget = new Text( parent, SWT.NONE | SWT.BORDER | SWT.READ_ONLY );
+        GridData gridData = new GridData( GridData.FILL_HORIZONTAL );
+        gridData.horizontalSpan = span;
+        textWidget.setLayoutData( gridData );
+        textWidget.setEditable( false );
+        textWidget.setBackground( parent.getBackground() );
+        textWidget.setText( text );
+        
+        return textWidget;
     }
 
 
@@ -375,14 +392,15 @@ public class BaseWidgetUtils
      */
     public static Combo createCombo( Composite parent, String[] items, int selectedIndex, int span )
     {
-        Combo c = new Combo( parent, SWT.DROP_DOWN | SWT.BORDER );
-        GridData gd = new GridData( GridData.FILL_HORIZONTAL );
-        gd.horizontalSpan = span;
-        c.setLayoutData( gd );
-        c.setItems( items );
-        c.select( selectedIndex );
-        c.setVisibleItemCount( 20 );
-        return c;
+        Combo combo = new Combo( parent, SWT.DROP_DOWN | SWT.BORDER );
+        GridData gridData = new GridData( GridData.FILL_HORIZONTAL );
+        gridData.horizontalSpan = span;
+        combo.setLayoutData( gridData );
+        combo.setItems( items );
+        combo.select( selectedIndex );
+        combo.setVisibleItemCount( 20 );
+        
+        return combo;
     }
 
 
@@ -399,15 +417,15 @@ public class BaseWidgetUtils
      */
     public static Combo createReadonlyCombo( Composite parent, String[] items, int selectedIndex, int span )
     {
-        Combo c = new Combo( parent, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER );
-        GridData gd = new GridData( GridData.FILL_HORIZONTAL );
-        gd.horizontalSpan = span;
-        c.setLayoutData( gd );
-        // c.setBackground(parent.getBackground());
-        c.setItems( items );
-        c.select( selectedIndex );
-        c.setVisibleItemCount( 20 );
-        return c;
+        Combo combo = new Combo( parent, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER );
+        GridData gridData = new GridData( GridData.FILL_HORIZONTAL );
+        gridData.horizontalSpan = span;
+        combo.setLayoutData( gridData );
+        combo.setItems( items );
+        combo.select( selectedIndex );
+        combo.setVisibleItemCount( 20 );
+        
+        return combo;
     }
 
 
@@ -423,9 +441,10 @@ public class BaseWidgetUtils
     {
         Button checkbox = new Button( parent, SWT.CHECK );
         checkbox.setText( text );
-        GridData gd = new GridData();
-        gd.horizontalSpan = span;
-        checkbox.setLayoutData( gd );
+        GridData gridData = new GridData();
+        gridData.horizontalSpan = span;
+        checkbox.setLayoutData( gridData );
+        
         return checkbox;
     }
 
@@ -442,9 +461,10 @@ public class BaseWidgetUtils
     {
         Button radio = new Button( parent, SWT.RADIO );
         radio.setText( text );
-        GridData gd = new GridData();
-        gd.horizontalSpan = span;
-        radio.setLayoutData( gd );
+        GridData gridData = new GridData();
+        gridData.horizontalSpan = span;
+        radio.setLayoutData( gridData );
+        
         return radio;
     }
 
@@ -466,11 +486,12 @@ public class BaseWidgetUtils
         gc.dispose();
 
         Button button = new Button( parent, SWT.PUSH );
-        GridData gd = new GridData();
-        gd.widthHint = Dialog.convertHorizontalDLUsToPixels( fontMetrics, IDialogConstants.BUTTON_WIDTH );
-        gd.horizontalSpan = span;
-        button.setLayoutData( gd );
+        GridData gridData = new GridData();
+        gridData.widthHint = Dialog.convertHorizontalDLUsToPixels( fontMetrics, IDialogConstants.BUTTON_WIDTH );
+        gridData.horizontalSpan = span;
+        button.setLayoutData( gridData );
         button.setText( text );
+        
         return button;
     }
 
@@ -484,12 +505,13 @@ public class BaseWidgetUtils
      */
     public static Label createRadioIndent( Composite parent, int span )
     {
-        Label l = new Label( parent, SWT.NONE );
-        GridData gd = new GridData();
-        gd.horizontalSpan = span;
-        gd.horizontalIndent = 22;
-        l.setLayoutData( gd );
-        return l;
+        Label label = new Label( parent, SWT.NONE );
+        GridData gridData = new GridData();
+        gridData.horizontalSpan = span;
+        gridData.horizontalIndent = 22;
+        label.setLayoutData( gridData );
+        
+        return label;
     }
 
 
@@ -502,12 +524,13 @@ public class BaseWidgetUtils
      */
     public static Label createSpacer( Composite parent, int span )
     {
-        Label l = new Label( parent, SWT.NONE );
-        GridData gd = new GridData();
-        gd.horizontalSpan = span;
-        gd.heightHint = 1;
-        l.setLayoutData( gd );
-        return l;
+        Label label = new Label( parent, SWT.NONE );
+        GridData gridData = new GridData();
+        gridData.horizontalSpan = span;
+        gridData.heightHint = 1;
+        label.setLayoutData( gridData );
+        
+        return label;
     }
 
 
@@ -520,11 +543,12 @@ public class BaseWidgetUtils
      */
     public static Label createSeparator( Composite parent, int span )
     {
-        Label l = new Label( parent, SWT.SEPARATOR | SWT.HORIZONTAL );
-        GridData gd = new GridData( GridData.FILL_HORIZONTAL );
-        gd.horizontalSpan = span;
-        l.setLayoutData( gd );
-        return l;
+        Label label = new Label( parent, SWT.SEPARATOR | SWT.HORIZONTAL );
+        GridData gridData = new GridData( GridData.FILL_HORIZONTAL );
+        gridData.horizontalSpan = span;
+        label.setLayoutData( gridData );
+        
+        return label;
     }
 
 
@@ -540,11 +564,102 @@ public class BaseWidgetUtils
     {
         Link link = new Link( parent, SWT.NONE );
         link.setText( text );
-        GridData gd = new GridData( SWT.FILL, SWT.BEGINNING, true, false );
-        gd.horizontalSpan = span;
-        gd.widthHint = 150;
-        link.setLayoutData( gd );
+        GridData gridData = new GridData( SWT.FILL, SWT.BEGINNING, true, false );
+        gridData.horizontalSpan = span;
+        gridData.widthHint = 150;
+        link.setLayoutData( gridData );
+        
         return link;
     }
+    
+    
+    /**
+     * Creates a Text that can be used to enter an integer.
+     *
+     * @param toolkit the toolkit
+     * @param parent the parent
+     * @return a Text that is a valid integer
+     */
+    public static Text createIntegerText( FormToolkit toolkit, Composite parent )
+    {
+        return createIntegerText( toolkit, parent, null, -1 );
+    }
 
+    
+    /**
+     * Creates a Text that can be used to enter an integer.
+     *
+     * @param toolkit the toolkit
+     * @param parent the parent
+     * @param width the size of the input text to use
+     * @return a Text that is a valid integer
+     */
+    public static Text createIntegerText( FormToolkit toolkit, Composite parent, int width )
+    {
+        return createIntegerText( toolkit, parent, null, width );
+    }
+
+    
+    /**
+     * Creates a Text that can be used to enter an integer.
+     *
+     * @param toolkit the toolkit
+     * @param parent the parent
+     * @param description the description that has to be added after the inmput text
+     * @return a Text that is a valid integer
+     */
+    public static Text createIntegerText( FormToolkit toolkit, Composite parent, String description )
+    {
+        return createIntegerText( toolkit, parent, description, -1 );
+    }
+
+    
+    /**
+     * Creates a Text that can be used to enter an integer.
+     *
+     * @param toolkit the toolkit
+     * @param parent the parent
+     * @param description the description that has to be added after the inmput text
+     * @param width the size of the input text to use
+     * @return a Text that is a valid integer
+     */
+    public static Text createIntegerText( FormToolkit toolkit, Composite parent, String description, int width )
+    {
+        Text integerText = toolkit.createText( parent, "" ); //$NON-NLS-1$
+        
+        integerText.addVerifyListener( new VerifyListener()
+        {
+            public void verifyText( VerifyEvent e )
+            {
+                for ( int i = 0; i < e.text.length(); i++ )
+                {
+                    if ( !Character.isDigit( e.text.charAt( i ) ) )
+                    {
+                        e.doit = false;
+                        break;
+                    }
+                }
+            }
+        } );
+
+        // Add the description, if needed
+        if ( ( description != null ) && ( description.length() > 0 ) )
+        {
+            ControlDecoration monitoringCheckboxDecoration = new ControlDecoration(
+                integerText, SWT.CENTER | SWT.RIGHT );
+            monitoringCheckboxDecoration.setImage( CommonUIPlugin.getDefault().getImageDescriptor(
+                CommonUIConstants.IMG_INFORMATION ).createImage() );
+            monitoringCheckboxDecoration.setMarginWidth( 4 );
+            monitoringCheckboxDecoration.setDescriptionText( description );
+        }
+        
+        if ( width >= 0 )
+        {
+            GridData gridData = new GridData();
+            gridData.widthHint = width;
+            integerText.setLayoutData( gridData );
+        }
+
+        return integerText;
+    }
 }