net.sf.zekr.ui.helper
Class FormUtils

java.lang.Object
  extended by net.sf.zekr.ui.helper.FormUtils

public class FormUtils
extends java.lang.Object

Since:
Zekr 1.0
Author:
Mohsen Saboorian

Field Summary
static java.lang.String URL_DATA
           
 
Constructor Summary
FormUtils()
           
 
Method Summary
static java.lang.String addAmpersand(java.lang.String menuText)
          check a menuText entry for an ampersand and if not found prepend the menuText with one
static void addEditableRow(org.eclipse.swt.widgets.Table table, java.lang.String str1, java.lang.String str2)
           
static void addLinkListener(org.eclipse.swt.widgets.Widget widget)
          Adds click listener to the link widget.
static void addRow(org.eclipse.swt.widgets.Table table, java.lang.String str1, java.lang.String str2)
           
static int buttonLength(org.eclipse.swt.widgets.Button button1, org.eclipse.swt.widgets.Button button2)
          Return the maximum length for a button when two buttons are given
static int buttonLength(org.eclipse.swt.widgets.Button button1, org.eclipse.swt.widgets.Button button2, org.eclipse.swt.widgets.Button button3)
          Return the maximum length for a button when three buttons are given.
static int buttonLength(int minimum, org.eclipse.swt.widgets.Button button1, org.eclipse.swt.widgets.Button button2)
          Return the maximum length for a button when two buttons and a minimum length are given.
static int buttonLength(int minimum, org.eclipse.swt.widgets.Button button1, org.eclipse.swt.widgets.Button button2, org.eclipse.swt.widgets.Button button3)
          return the maximum length for a button when three buttons and a minimum length are given
static org.eclipse.swt.graphics.Point getCenter(org.eclipse.swt.widgets.Shell parent, org.eclipse.swt.widgets.Shell shell)
           
static org.eclipse.swt.widgets.Table getEditableTable(org.eclipse.swt.widgets.Composite parent, java.util.Map map, java.lang.String title1, java.lang.String title2, int width1, int width2, java.lang.Object layoutData, int style)
           
static org.eclipse.swt.graphics.Point getScreenCenter(org.eclipse.swt.widgets.Display display, org.eclipse.swt.graphics.Rectangle widgetSize)
          This method shall be used to find upper-left position of a Rectangle, which then be centered on the screen.
static org.eclipse.swt.graphics.Point getScreenSize(org.eclipse.swt.widgets.Display display)
           
static org.eclipse.swt.widgets.Table getTableFromMap(org.eclipse.swt.widgets.Composite parent, java.util.Map map, java.lang.String title1, java.lang.String title2, int width1, int width2, java.lang.Object layoutData, int style)
           
static void limitSize(org.eclipse.swt.widgets.Shell shell, int width, int height)
          Limits the size of the shell to the given values.
static void removeSelection(org.eclipse.swt.widgets.Table table)
           
static int toSwtDirection(java.lang.String direction)
           
static void updateTable(org.eclipse.swt.widgets.Table table, java.util.Map map)
          For internal use only.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

URL_DATA

public static final java.lang.String URL_DATA
See Also:
Constant Field Values
Constructor Detail

FormUtils

public FormUtils()
Method Detail

getScreenSize

public static org.eclipse.swt.graphics.Point getScreenSize(org.eclipse.swt.widgets.Display display)
Parameters:
display - The Device to extract it's bounds.
Returns:
A Point containing (maxX, maxY) of device.

getScreenCenter

public static org.eclipse.swt.graphics.Point getScreenCenter(org.eclipse.swt.widgets.Display display,
                                                             org.eclipse.swt.graphics.Rectangle widgetSize)
This method shall be used to find upper-left position of a Rectangle, which then be centered on the screen.

Parameters:
display - The display to extract it's bounds.
widgetSize - widget size and position.
Returns:
Proper (x, y) value.

getTableFromMap

public static org.eclipse.swt.widgets.Table getTableFromMap(org.eclipse.swt.widgets.Composite parent,
                                                            java.util.Map map,
                                                            java.lang.String title1,
                                                            java.lang.String title2,
                                                            int width1,
                                                            int width2,
                                                            java.lang.Object layoutData,
                                                            int style)

getEditableTable

public static org.eclipse.swt.widgets.Table getEditableTable(org.eclipse.swt.widgets.Composite parent,
                                                             java.util.Map map,
                                                             java.lang.String title1,
                                                             java.lang.String title2,
                                                             int width1,
                                                             int width2,
                                                             java.lang.Object layoutData,
                                                             int style)

addRow

public static void addRow(org.eclipse.swt.widgets.Table table,
                          java.lang.String str1,
                          java.lang.String str2)

addEditableRow

public static void addEditableRow(org.eclipse.swt.widgets.Table table,
                                  java.lang.String str1,
                                  java.lang.String str2)

updateTable

public static void updateTable(org.eclipse.swt.widgets.Table table,
                               java.util.Map map)
For internal use only.


toSwtDirection

public static int toSwtDirection(java.lang.String direction)
Parameters:
direction - can be either rtl or ltr
Returns:
SWT.RIGHT_TO_LEFT if direction is rtl (ignoring the case), SWT.LEFT_TO_RIGHT otherwise.

removeSelection

public static void removeSelection(org.eclipse.swt.widgets.Table table)

getCenter

public static org.eclipse.swt.graphics.Point getCenter(org.eclipse.swt.widgets.Shell parent,
                                                       org.eclipse.swt.widgets.Shell shell)

addAmpersand

public static java.lang.String addAmpersand(java.lang.String menuText)
check a menuText entry for an ampersand and if not found prepend the menuText with one

Parameters:
menuText - the menuText to be shown, i.e. the translated text with possible & markers to show which key on the keyboard will activate the menu item
Returns:
either menuText with an & marker in the first position if there was no & menuText without any modification if there already was a & included

buttonLength

public static int buttonLength(org.eclipse.swt.widgets.Button button1,
                               org.eclipse.swt.widgets.Button button2)
Return the maximum length for a button when two buttons are given

Parameters:
button1 - a first button Button object
button2 - a second button Button object
Returns:
int max length of the two buttons given

buttonLength

public static int buttonLength(int minimum,
                               org.eclipse.swt.widgets.Button button1,
                               org.eclipse.swt.widgets.Button button2)
Return the maximum length for a button when two buttons and a minimum length are given.

Parameters:
minimum - an integer giving the minimum length a button has to have
button1 - a first button Button object
button2 - a second button Button object
Returns:
int max length of the two buttons given

buttonLength

public static int buttonLength(org.eclipse.swt.widgets.Button button1,
                               org.eclipse.swt.widgets.Button button2,
                               org.eclipse.swt.widgets.Button button3)
Return the maximum length for a button when three buttons are given.

Parameters:
button1 - a first button
button2 - a second button
Returns:
int max length of the two buttons given

buttonLength

public static int buttonLength(int minimum,
                               org.eclipse.swt.widgets.Button button1,
                               org.eclipse.swt.widgets.Button button2,
                               org.eclipse.swt.widgets.Button button3)
return the maximum length for a button when three buttons and a minimum length are given

Parameters:
minimum - an integer giving the minimum length a button has to have
button1 - a first button
button2 - a second button
Returns:
int max length of the two buttons given

addLinkListener

public static void addLinkListener(org.eclipse.swt.widgets.Widget widget)
Adds click listener to the link widget.

Parameters:
widget -

limitSize

public static void limitSize(org.eclipse.swt.widgets.Shell shell,
                             int width,
                             int height)
Limits the size of the shell to the given values.

Parameters:
shell - the Shell to limit