1 package org
.argeo
.eclipse
.ui
;
3 import org
.eclipse
.jface
.resource
.JFaceResources
;
4 import org
.eclipse
.swt
.SWT
;
5 import org
.eclipse
.swt
.events
.ModifyListener
;
6 import org
.eclipse
.swt
.graphics
.Font
;
7 import org
.eclipse
.swt
.layout
.GridData
;
8 import org
.eclipse
.swt
.widgets
.Composite
;
9 import org
.eclipse
.swt
.widgets
.Label
;
10 import org
.eclipse
.swt
.widgets
.Text
;
12 /** Utilities to simplify UI development. */
13 public class EclipseUiUtils
{
15 * Create a label and a text field for a grid layout, the text field grabing
19 * the parent composite
21 * the lable to display
22 * @param modifyListener
23 * a {@link ModifyListener} to listen on events on the text, can
25 * @return the created text
27 * @deprecated use {@link #createGridLT(Composite, String)} instead
30 public static Text
createGridLT(Composite parent
, String label
,
31 ModifyListener modifyListener
) {
32 Label lbl
= new Label(parent
, SWT
.LEAD
);
34 lbl
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false));
35 Text txt
= new Text(parent
, SWT
.LEAD
| SWT
.BORDER
);
36 txt
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
37 if (modifyListener
!= null)
38 txt
.addModifyListener(modifyListener
);
42 public static Text
createGridLT(Composite parent
, String label
) {
43 return createGridLT(parent
, label
, null);
47 * Creates one label and a text field not editable with background color of
48 * the parent (like a label but with selectable text)
50 public static Text
createGridLL(Composite parent
, String label
, String text
) {
51 Text txt
= createGridLT(parent
, label
);
53 txt
.setEditable(false);
54 txt
.setBackground(parent
.getBackground());
58 public static Text
createGridLP(Composite parent
, String label
,
59 ModifyListener modifyListener
) {
60 Label lbl
= new Label(parent
, SWT
.LEAD
);
62 lbl
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false));
63 Text txt
= new Text(parent
, SWT
.LEAD
| SWT
.BORDER
| SWT
.PASSWORD
);
64 txt
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
66 txt
.addModifyListener(modifyListener
);
70 public static Font
getItalicFont(Composite parent
) {
71 return JFaceResources
.getFontRegistry().defaultFontDescriptor()
72 .setStyle(SWT
.ITALIC
).createFont(parent
.getDisplay());
75 public static Font
getBoldFont(Composite parent
) {
76 return JFaceResources
.getFontRegistry().defaultFontDescriptor()
77 .setStyle(SWT
.BOLD
).createFont(parent
.getDisplay());
80 public static Font
getBoldItalicFont(Composite parent
) {
81 return JFaceResources
.getFontRegistry().defaultFontDescriptor()
82 .setStyle(SWT
.BOLD
| SWT
.ITALIC
)
83 .createFont(parent
.getDisplay());