org.dawb.common.ui.util
Class GridUtils

java.lang.Object
  extended by org.dawb.common.ui.util.GridUtils

public class GridUtils
extends java.lang.Object

Class to deal with setting items in a grid layout invisible. Allows batch updating of controls to reduce flicker


Constructor Summary
GridUtils()
           
 
Method Summary
static void endMultiLayout()
          End a batch layout update.
static void layout(org.eclipse.swt.widgets.Composite control)
          Calls layout on the control, deferring the call if within a start/endMultiLayout call.
static void layoutFull(org.eclipse.swt.widgets.Composite control)
          Calls layout on the control, deferring the call if within a start/endMultiLayout call.
static void removeMargins(org.eclipse.swt.widgets.Composite area)
           
static void setVisible(org.eclipse.swt.widgets.Control widget, boolean isVisible)
          Simplified version of setVisibleAndLayout(...) which cannot cause a memory leak.
static void setVisibleAndLayout(org.eclipse.swt.widgets.Control widget, boolean isVisible)
          Changes visibility and layout of a control.
static void startMultiLayout(org.eclipse.swt.widgets.Control parent)
          Start a batch layout update.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GridUtils

public GridUtils()
Method Detail

startMultiLayout

public static void startMultiLayout(org.eclipse.swt.widgets.Control parent)
Start a batch layout update. Wrap multiple calls to setVisibleAndLayout or layout with start/end MultLayout.

Calls to startMultiLayout can be nested as a stack is used internally. The last call to endMultiLayout causes all the layouts to happen at once.

Parameters:
parent - a suitable control that encompasses all the controls that may have their visibility changed. parent is optional and can be null. If parent is "wrong" or null the effect is simply to have slightly more flicker in the UI that optimal

endMultiLayout

public static void endMultiLayout()
End a batch layout update. If the stack is empty, the all the controls that have had layout updated will now be laid out and redrawn.


setVisibleAndLayout

public static void setVisibleAndLayout(org.eclipse.swt.widgets.Control widget,
                                       boolean isVisible)
Changes visibility and layout of a control. Takes into consideration excluding the control from the GridData layout manager.

If this function is called within the scope of startMultiLayout, the final steps of layout will not take effect until endMultiLayout is called.

Parameters:
widget - the widget to make visible or invisible
isVisible - is true to make widget visible, false to hide it

setVisible

public static void setVisible(org.eclipse.swt.widgets.Control widget,
                              boolean isVisible)
Simplified version of setVisibleAndLayout(...) which cannot cause a memory leak. Does not work with startMultiLayout() and endMultiLayout() You need to call layout once on the parent widget after using this method. For instance: GridUtils.setVisible(wLabel, wVisible); GridUtils.setVisible(w, wVisible); GridUtils.setVisible(kLabel, kVisible); GridUtils.setVisible(kStart, kVisible); getShell().layout();

Parameters:
widget -
isVisible -

layout

public static void layout(org.eclipse.swt.widgets.Composite control)
Calls layout on the control, deferring the call if within a start/endMultiLayout call. Use this version of layout only when you are sure that the bounding box has not changed, otherwise, use layoutFull

Parameters:
control - is the widget to re-layout

layoutFull

public static void layoutFull(org.eclipse.swt.widgets.Composite control)
Calls layout on the control, deferring the call if within a start/endMultiLayout call. As opposed to layout(), this forces a full layout.

Parameters:
control - is the widget to re-layout

removeMargins

public static void removeMargins(org.eclipse.swt.widgets.Composite area)
Parameters:
area -