Mercurial > projects > dwt-addons
diff dwtx/draw2d/BorderLayout.d @ 103:2d6540440fe6
Replace static ctors with lazy init.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 03 Aug 2008 17:01:51 +0200 |
parents | 95307ad235d9 |
children |
line wrap: on
line diff
--- a/dwtx/draw2d/BorderLayout.d Sun Aug 03 03:07:30 2008 +0200 +++ b/dwtx/draw2d/BorderLayout.d Sun Aug 03 17:01:51 2008 +0200 @@ -31,30 +31,56 @@ /** * Constant to be used as a constraint for child figures */ -public static const Integer CENTER; +private static Integer CENTER_; +public static Integer CENTER(){ + if( !initStaticCtor_done ) initStaticCtor(); + return CENTER_; +} /** * Constant to be used as a constraint for child figures */ -public static const Integer TOP; +private static Integer TOP_; +public static Integer TOP(){ + if( !initStaticCtor_done ) initStaticCtor(); + return TOP_; +} /** * Constant to be used as a constraint for child figures */ -public static const Integer BOTTOM; +private static Integer BOTTOM_; +public static Integer BOTTOM(){ + if( !initStaticCtor_done ) initStaticCtor(); + return BOTTOM_; +} /** * Constant to be used as a constraint for child figures */ -public static const Integer LEFT; +private static Integer LEFT_; +public static Integer LEFT(){ + if( !initStaticCtor_done ) initStaticCtor(); + return LEFT_; +} /** * Constant to be used as a constraint for child figures */ -public static const Integer RIGHT; +private static Integer RIGHT_; +public static Integer RIGHT(){ + if( !initStaticCtor_done ) initStaticCtor(); + return RIGHT_; +} -static this(){ - CENTER = new Integer(PositionConstants.CENTER); - TOP = new Integer(PositionConstants.TOP); - BOTTOM = new Integer(PositionConstants.BOTTOM); - LEFT = new Integer(PositionConstants.LEFT); - RIGHT = new Integer(PositionConstants.RIGHT); +private static bool initStaticCtor_done = false; +private static void initStaticCtor(){ + synchronized( BorderLayout.classinfo ){ + if( !initStaticCtor_done ){ + CENTER_ = new Integer(PositionConstants.CENTER); + TOP_ = new Integer(PositionConstants.TOP); + BOTTOM_ = new Integer(PositionConstants.BOTTOM); + LEFT_ = new Integer(PositionConstants.LEFT); + RIGHT_ = new Integer(PositionConstants.RIGHT); + initStaticCtor_done = true; + } + } } private IFigure center, left, top, bottom, right;