Mercurial > projects > dwt-addons
comparison dwtx/jface/dialogs/PopupDialog.d @ 72:5df4896124c7
JFace and its examples do compile
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Thu, 22 May 2008 17:56:17 +0200 |
parents | 4878bef4a38e |
children | 7ffeace6c47f |
comparison
equal
deleted
inserted
replaced
71:4878bef4a38e | 72:5df4896124c7 |
---|---|
53 import dwtx.jface.layout.GridLayoutFactory; | 53 import dwtx.jface.layout.GridLayoutFactory; |
54 import dwtx.jface.resource.JFaceResources; | 54 import dwtx.jface.resource.JFaceResources; |
55 import dwtx.jface.window.Window; | 55 import dwtx.jface.window.Window; |
56 | 56 |
57 import dwt.dwthelper.utils; | 57 import dwt.dwthelper.utils; |
58 import dwt.dwthelper.Runnable; | |
58 | 59 |
59 /** | 60 /** |
60 * A lightweight, transient dialog that is popped up to show contextual or | 61 * A lightweight, transient dialog that is popped up to show contextual or |
61 * temporal information and is easily dismissed. Clients control whether the | 62 * temporal information and is easily dismissed. Clients control whether the |
62 * dialog should be able to receive input focus. An optional title area at the | 63 * dialog should be able to receive input focus. An optional title area at the |
79 public class PopupDialog : Window { | 80 public class PopupDialog : Window { |
80 | 81 |
81 /** | 82 /** |
82 * | 83 * |
83 */ | 84 */ |
84 private static const GridDataFactory LAYOUTDATA_GRAB_BOTH; | 85 private static GridDataFactory LAYOUTDATA_GRAB_BOTH_; |
86 private static GridDataFactory LAYOUTDATA_GRAB_BOTH(){ | |
87 if( LAYOUTDATA_GRAB_BOTH_ is null ){ | |
88 synchronized( PopupDialog.classinfo ){ | |
89 if( LAYOUTDATA_GRAB_BOTH_ is null ){ | |
90 LAYOUTDATA_GRAB_BOTH_ = GridDataFactory.fillDefaults().grab(true,true); | |
91 } | |
92 } | |
93 } | |
94 return LAYOUTDATA_GRAB_BOTH_; | |
95 } | |
85 | 96 |
86 /** | 97 /** |
87 * The dialog settings key name for stored dialog x location. | 98 * The dialog settings key name for stored dialog x location. |
88 */ | 99 */ |
89 private static const String DIALOG_ORIGIN_X = "DIALOG_X_ORIGIN"; //$NON-NLS-1$ | 100 private static const String DIALOG_ORIGIN_X = "DIALOG_X_ORIGIN"; //$NON-NLS-1$ |
283 /** | 294 /** |
284 * Image registry key for menu image. | 295 * Image registry key for menu image. |
285 * | 296 * |
286 * @since 3.3 | 297 * @since 3.3 |
287 */ | 298 */ |
288 public static final String POPUP_IMG_MENU = "popup_menu_image"; //$NON-NLS-1$ | 299 public static const String POPUP_IMG_MENU = "popup_menu_image"; //$NON-NLS-1$ |
289 | 300 |
290 /** | 301 /** |
291 * Image registry key for disabled menu image. | 302 * Image registry key for disabled menu image. |
292 * | 303 * |
293 * @since 3.3 | 304 * @since 3.3 |
294 */ | 305 */ |
295 public static final String POPUP_IMG_MENU_DISABLED = "popup_menu_image_diabled"; //$NON-NLS-1$ | 306 public static const String POPUP_IMG_MENU_DISABLED = "popup_menu_image_diabled"; //$NON-NLS-1$ |
296 | 307 |
297 /** | 308 /** |
298 * | 309 * |
299 */ | 310 */ |
300 private static final GridLayoutFactory POPUP_LAYOUT_FACTORY; | 311 private static GridLayoutFactory POPUP_LAYOUT_FACTORY_; |
301 | 312 private static GridLayoutFactory POPUP_LAYOUT_FACTORY() { |
302 static this(){ | 313 if( POPUP_LAYOUT_FACTORY_ is null ){ |
303 LAYOUTDATA_GRAB_BOTH = GridDataFactory.fillDefaults().grab(true,true); | 314 synchronized( PopupDialog.classinfo ){ |
304 POPUP_LAYOUT_FACTORY = GridLayoutFactory | 315 if( POPUP_LAYOUT_FACTORY_ is null ){ |
305 .fillDefaults().margins(POPUP_MARGINWIDTH, POPUP_MARGINHEIGHT) | 316 POPUP_LAYOUT_FACTORY_ = GridLayoutFactory |
306 .spacing(POPUP_HORIZONTALSPACING, POPUP_VERTICALSPACING); | 317 .fillDefaults().margins(POPUP_MARGINWIDTH, POPUP_MARGINHEIGHT) |
318 .spacing(POPUP_HORIZONTALSPACING, POPUP_VERTICALSPACING); | |
319 } | |
320 } | |
321 } | |
322 return POPUP_LAYOUT_FACTORY_; | |
307 } | 323 } |
308 | 324 |
309 /** | 325 /** |
310 * The dialog's toolbar for the move and resize capabilities. | 326 * The dialog's toolbar for the move and resize capabilities. |
311 */ | 327 */ |
833 */ | 849 */ |
834 protected Control createTitleControl(Composite parent) { | 850 protected Control createTitleControl(Composite parent) { |
835 titleLabel = new Label(parent, DWT.NONE); | 851 titleLabel = new Label(parent, DWT.NONE); |
836 | 852 |
837 GridDataFactory.fillDefaults().align_(DWT.FILL, DWT.CENTER).grab(true, | 853 GridDataFactory.fillDefaults().align_(DWT.FILL, DWT.CENTER).grab(true, |
838 false).span(showDialogMenu ? 1 : 2, 1).applyTo(titleLabel); | 854 false).span(showDialogMenu_ ? 1 : 2, 1).applyTo(titleLabel); |
839 | 855 |
840 if (titleText !is null) { | 856 if (titleText !is null) { |
841 titleLabel.setText(titleText); | 857 titleLabel.setText(titleText); |
842 } | 858 } |
843 return titleLabel; | 859 return titleLabel; |
1206 } | 1222 } |
1207 if (persistLocation) { | 1223 if (persistLocation) { |
1208 settings.put(prefix ~ DIALOG_ORIGIN_X, shellLocation.x); | 1224 settings.put(prefix ~ DIALOG_ORIGIN_X, shellLocation.x); |
1209 settings.put(prefix ~ DIALOG_ORIGIN_Y, shellLocation.y); | 1225 settings.put(prefix ~ DIALOG_ORIGIN_Y, shellLocation.y); |
1210 } | 1226 } |
1211 if (showPersistActions && showDialogMenu) { | 1227 if (showPersistActions && showDialogMenu_) { |
1212 settings.put(getClass().getName() + DIALOG_USE_PERSISTED_SIZE, | 1228 settings.put(this.classinfo.name ~ DIALOG_USE_PERSISTED_SIZE, |
1213 persistSize); | 1229 persistSize); |
1214 settings.put(getClass().getName() | 1230 settings.put(this.classinfo.name |
1215 + DIALOG_USE_PERSISTED_LOCATION, persistLocation); | 1231 ~ DIALOG_USE_PERSISTED_LOCATION, persistLocation); |
1216 | 1232 |
1217 } | 1233 } |
1218 } | 1234 } |
1219 } | 1235 } |
1220 | 1236 |
1580 private void migrateBoundsSetting() { | 1596 private void migrateBoundsSetting() { |
1581 IDialogSettings settings = getDialogSettings(); | 1597 IDialogSettings settings = getDialogSettings(); |
1582 if (settings is null) | 1598 if (settings is null) |
1583 return; | 1599 return; |
1584 | 1600 |
1585 final String className = getClass().getName(); | 1601 final String className = this.classinfo.name; |
1586 | 1602 |
1587 String key = className + DIALOG_USE_PERSISTED_BOUNDS; | 1603 String key = className ~ DIALOG_USE_PERSISTED_BOUNDS; |
1588 String value = settings.get(key); | 1604 String value = settings.get(key); |
1589 if (value is null || DIALOG_VALUE_MIGRATED_TO_34.equals(value)) | 1605 if (value is null || DIALOG_VALUE_MIGRATED_TO_34.equals(value)) |
1590 return; | 1606 return; |
1591 | 1607 |
1592 bool storeBounds = settings.getBoolean(key); | 1608 bool storeBounds = settings.getBoolean(key); |
1593 settings.put(className + DIALOG_USE_PERSISTED_LOCATION, storeBounds); | 1609 settings.put(className ~ DIALOG_USE_PERSISTED_LOCATION, storeBounds); |
1594 settings.put(className + DIALOG_USE_PERSISTED_SIZE, storeBounds); | 1610 settings.put(className ~ DIALOG_USE_PERSISTED_SIZE, storeBounds); |
1595 settings.put(key, DIALOG_VALUE_MIGRATED_TO_34); | 1611 settings.put(key, DIALOG_VALUE_MIGRATED_TO_34); |
1596 } | 1612 } |
1597 | 1613 |
1598 /** | 1614 /** |
1599 * The dialog is being disposed. Dispose of any resources allocated. | 1615 * The dialog is being disposed. Dispose of any resources allocated. |