]> git.argeo.org Git - lgpl/argeo-commons.git/blob - EclipseUiUtils.java
e70d819d19e69c922a6534256830a5a18d4b89d9
[lgpl/argeo-commons.git] / EclipseUiUtils.java
1 package org.argeo.eclipse.ui;
2
3 import org.eclipse.swt.SWT;
4 import org.eclipse.swt.events.ModifyListener;
5 import org.eclipse.swt.layout.GridData;
6 import org.eclipse.swt.widgets.Composite;
7 import org.eclipse.swt.widgets.Label;
8 import org.eclipse.swt.widgets.Text;
9
10 /** Utilities to simplify UI development. */
11 public class EclipseUiUtils {
12 /**
13 * Create a label and a text field for a grid layout, the text field grabing
14 * excess horizontal
15 *
16 * @param parent
17 * the parent composite
18 * @param label
19 * the lable to display
20 * @param modifyListener
21 * a {@link ModifyListener} to listen on events on the text, can
22 * be null
23 * @return the created text
24 */
25 public static Text createGridLT(Composite parent, String label,
26 ModifyListener modifyListener) {
27 Label lbl = new Label(parent, SWT.LEAD);
28 lbl.setText(label);
29 lbl.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
30 Text txt = new Text(parent, SWT.LEAD | SWT.BORDER);
31 txt.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
32 if (txt != null)
33 txt.addModifyListener(modifyListener);
34 return txt;
35 }
36
37 public static Text createGridLP(Composite parent, String label,
38 ModifyListener modifyListener) {
39 Label lbl = new Label(parent, SWT.LEAD);
40 lbl.setText(label);
41 lbl.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
42 Text txt = new Text(parent, SWT.LEAD | SWT.BORDER | SWT.PASSWORD);
43 txt.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
44 if (txt != null)
45 txt.addModifyListener(modifyListener);
46 return txt;
47 }
48
49 }